diff --git a/bj_power_mes/ent/bomitem.go b/bj_power_mes/ent/bomitem.go index dfd6e27..e298bcd 100644 --- a/bj_power_mes/ent/bomitem.go +++ b/bj_power_mes/ent/bomitem.go @@ -30,6 +30,8 @@ type BomItem struct { Unit string `json:"unit,omitempty"` // ManageMode holds the value of the "manageMode" field. ManageMode string `json:"manageMode,omitempty"` + // 装配工序 1~12,0=不参与工位绑定 + ProcessCode int `json:"processCode,omitempty"` // 单台用量 UnitQty float64 `json:"unitQty,omitempty"` // 损耗率% @@ -52,7 +54,7 @@ func (*BomItem) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case bomitem.FieldUnitQty, bomitem.FieldLossRate, bomitem.FieldRequiredQty: values[i] = new(sql.NullFloat64) - case bomitem.FieldID: + case bomitem.FieldID, bomitem.FieldProcessCode: values[i] = new(sql.NullInt64) case bomitem.FieldProductCode, bomitem.FieldMaterialCode, bomitem.FieldMaterialName, bomitem.FieldSpec, bomitem.FieldUnit, bomitem.FieldManageMode: values[i] = new(sql.NullString) @@ -115,6 +117,12 @@ func (_m *BomItem) assignValues(columns []string, values []any) error { } else if value.Valid { _m.ManageMode = value.String } + case bomitem.FieldProcessCode: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field processCode", values[i]) + } else if value.Valid { + _m.ProcessCode = int(value.Int64) + } case bomitem.FieldUnitQty: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field unitQty", values[i]) @@ -201,6 +209,9 @@ func (_m *BomItem) String() string { builder.WriteString("manageMode=") builder.WriteString(_m.ManageMode) builder.WriteString(", ") + builder.WriteString("processCode=") + builder.WriteString(fmt.Sprintf("%v", _m.ProcessCode)) + builder.WriteString(", ") builder.WriteString("unitQty=") builder.WriteString(fmt.Sprintf("%v", _m.UnitQty)) builder.WriteString(", ") diff --git a/bj_power_mes/ent/bomitem/bomitem.go b/bj_power_mes/ent/bomitem/bomitem.go index a0e41c3..45a34ee 100644 --- a/bj_power_mes/ent/bomitem/bomitem.go +++ b/bj_power_mes/ent/bomitem/bomitem.go @@ -25,6 +25,8 @@ const ( FieldUnit = "unit" // FieldManageMode holds the string denoting the managemode field in the database. FieldManageMode = "manage_mode" + // FieldProcessCode holds the string denoting the processcode field in the database. + FieldProcessCode = "process_code" // FieldUnitQty holds the string denoting the unitqty field in the database. FieldUnitQty = "unit_qty" // FieldLossRate holds the string denoting the lossrate field in the database. @@ -48,6 +50,7 @@ var Columns = []string{ FieldSpec, FieldUnit, FieldManageMode, + FieldProcessCode, FieldUnitQty, FieldLossRate, FieldRequiredQty, @@ -88,6 +91,8 @@ var ( DefaultManageMode string // ManageModeValidator is a validator for the "manageMode" field. It is called by the builders before save. ManageModeValidator func(string) error + // DefaultProcessCode holds the default value on creation for the "processCode" field. + DefaultProcessCode int // DefaultUnitQty holds the default value on creation for the "unitQty" field. DefaultUnitQty float64 // DefaultLossRate holds the default value on creation for the "lossRate" field. @@ -138,6 +143,11 @@ func ByManageMode(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldManageMode, opts...).ToFunc() } +// ByProcessCode orders the results by the processCode field. +func ByProcessCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProcessCode, opts...).ToFunc() +} + // ByUnitQty orders the results by the unitQty field. func ByUnitQty(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUnitQty, opts...).ToFunc() diff --git a/bj_power_mes/ent/bomitem/where.go b/bj_power_mes/ent/bomitem/where.go index 3c1aebc..944f34a 100644 --- a/bj_power_mes/ent/bomitem/where.go +++ b/bj_power_mes/ent/bomitem/where.go @@ -84,6 +84,11 @@ func ManageMode(v string) predicate.BomItem { return predicate.BomItem(sql.FieldEQ(FieldManageMode, v)) } +// ProcessCode applies equality check predicate on the "processCode" field. It's identical to ProcessCodeEQ. +func ProcessCode(v int) predicate.BomItem { + return predicate.BomItem(sql.FieldEQ(FieldProcessCode, v)) +} + // UnitQty applies equality check predicate on the "unitQty" field. It's identical to UnitQtyEQ. func UnitQty(v float64) predicate.BomItem { return predicate.BomItem(sql.FieldEQ(FieldUnitQty, v)) @@ -494,6 +499,46 @@ func ManageModeContainsFold(v string) predicate.BomItem { return predicate.BomItem(sql.FieldContainsFold(FieldManageMode, v)) } +// ProcessCodeEQ applies the EQ predicate on the "processCode" field. +func ProcessCodeEQ(v int) predicate.BomItem { + return predicate.BomItem(sql.FieldEQ(FieldProcessCode, v)) +} + +// ProcessCodeNEQ applies the NEQ predicate on the "processCode" field. +func ProcessCodeNEQ(v int) predicate.BomItem { + return predicate.BomItem(sql.FieldNEQ(FieldProcessCode, v)) +} + +// ProcessCodeIn applies the In predicate on the "processCode" field. +func ProcessCodeIn(vs ...int) predicate.BomItem { + return predicate.BomItem(sql.FieldIn(FieldProcessCode, vs...)) +} + +// ProcessCodeNotIn applies the NotIn predicate on the "processCode" field. +func ProcessCodeNotIn(vs ...int) predicate.BomItem { + return predicate.BomItem(sql.FieldNotIn(FieldProcessCode, vs...)) +} + +// ProcessCodeGT applies the GT predicate on the "processCode" field. +func ProcessCodeGT(v int) predicate.BomItem { + return predicate.BomItem(sql.FieldGT(FieldProcessCode, v)) +} + +// ProcessCodeGTE applies the GTE predicate on the "processCode" field. +func ProcessCodeGTE(v int) predicate.BomItem { + return predicate.BomItem(sql.FieldGTE(FieldProcessCode, v)) +} + +// ProcessCodeLT applies the LT predicate on the "processCode" field. +func ProcessCodeLT(v int) predicate.BomItem { + return predicate.BomItem(sql.FieldLT(FieldProcessCode, v)) +} + +// ProcessCodeLTE applies the LTE predicate on the "processCode" field. +func ProcessCodeLTE(v int) predicate.BomItem { + return predicate.BomItem(sql.FieldLTE(FieldProcessCode, v)) +} + // UnitQtyEQ applies the EQ predicate on the "unitQty" field. func UnitQtyEQ(v float64) predicate.BomItem { return predicate.BomItem(sql.FieldEQ(FieldUnitQty, v)) diff --git a/bj_power_mes/ent/bomitem_create.go b/bj_power_mes/ent/bomitem_create.go index 9c56dd8..6766045 100644 --- a/bj_power_mes/ent/bomitem_create.go +++ b/bj_power_mes/ent/bomitem_create.go @@ -96,6 +96,20 @@ func (_c *BomItemCreate) SetNillableManageMode(v *string) *BomItemCreate { return _c } +// SetProcessCode sets the "processCode" field. +func (_c *BomItemCreate) SetProcessCode(v int) *BomItemCreate { + _c.mutation.SetProcessCode(v) + return _c +} + +// SetNillableProcessCode sets the "processCode" field if the given value is not nil. +func (_c *BomItemCreate) SetNillableProcessCode(v *int) *BomItemCreate { + if v != nil { + _c.SetProcessCode(*v) + } + return _c +} + // SetUnitQty sets the "unitQty" field. func (_c *BomItemCreate) SetUnitQty(v float64) *BomItemCreate { _c.mutation.SetUnitQty(v) @@ -219,6 +233,10 @@ func (_c *BomItemCreate) defaults() { v := bomitem.DefaultManageMode _c.mutation.SetManageMode(v) } + if _, ok := _c.mutation.ProcessCode(); !ok { + v := bomitem.DefaultProcessCode + _c.mutation.SetProcessCode(v) + } if _, ok := _c.mutation.UnitQty(); !ok { v := bomitem.DefaultUnitQty _c.mutation.SetUnitQty(v) @@ -287,6 +305,9 @@ func (_c *BomItemCreate) check() error { return &ValidationError{Name: "manageMode", err: fmt.Errorf(`ent: validator failed for field "BomItem.manageMode": %w`, err)} } } + if _, ok := _c.mutation.ProcessCode(); !ok { + return &ValidationError{Name: "processCode", err: errors.New(`ent: missing required field "BomItem.processCode"`)} + } if _, ok := _c.mutation.UnitQty(); !ok { return &ValidationError{Name: "unitQty", err: errors.New(`ent: missing required field "BomItem.unitQty"`)} } @@ -360,6 +381,10 @@ func (_c *BomItemCreate) createSpec() (*BomItem, *sqlgraph.CreateSpec) { _spec.SetField(bomitem.FieldManageMode, field.TypeString, value) _node.ManageMode = value } + if value, ok := _c.mutation.ProcessCode(); ok { + _spec.SetField(bomitem.FieldProcessCode, field.TypeInt, value) + _node.ProcessCode = value + } if value, ok := _c.mutation.UnitQty(); ok { _spec.SetField(bomitem.FieldUnitQty, field.TypeFloat64, value) _node.UnitQty = value diff --git a/bj_power_mes/ent/bomitem_update.go b/bj_power_mes/ent/bomitem_update.go index b58eb8f..bbbc6a8 100644 --- a/bj_power_mes/ent/bomitem_update.go +++ b/bj_power_mes/ent/bomitem_update.go @@ -113,6 +113,27 @@ func (_u *BomItemUpdate) SetNillableManageMode(v *string) *BomItemUpdate { return _u } +// SetProcessCode sets the "processCode" field. +func (_u *BomItemUpdate) SetProcessCode(v int) *BomItemUpdate { + _u.mutation.ResetProcessCode() + _u.mutation.SetProcessCode(v) + return _u +} + +// SetNillableProcessCode sets the "processCode" field if the given value is not nil. +func (_u *BomItemUpdate) SetNillableProcessCode(v *int) *BomItemUpdate { + if v != nil { + _u.SetProcessCode(*v) + } + return _u +} + +// AddProcessCode adds value to the "processCode" field. +func (_u *BomItemUpdate) AddProcessCode(v int) *BomItemUpdate { + _u.mutation.AddProcessCode(v) + return _u +} + // SetUnitQty sets the "unitQty" field. func (_u *BomItemUpdate) SetUnitQty(v float64) *BomItemUpdate { _u.mutation.ResetUnitQty() @@ -297,6 +318,12 @@ func (_u *BomItemUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.ManageMode(); ok { _spec.SetField(bomitem.FieldManageMode, field.TypeString, value) } + if value, ok := _u.mutation.ProcessCode(); ok { + _spec.SetField(bomitem.FieldProcessCode, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProcessCode(); ok { + _spec.AddField(bomitem.FieldProcessCode, field.TypeInt, value) + } if value, ok := _u.mutation.UnitQty(); ok { _spec.SetField(bomitem.FieldUnitQty, field.TypeFloat64, value) } @@ -432,6 +459,27 @@ func (_u *BomItemUpdateOne) SetNillableManageMode(v *string) *BomItemUpdateOne { return _u } +// SetProcessCode sets the "processCode" field. +func (_u *BomItemUpdateOne) SetProcessCode(v int) *BomItemUpdateOne { + _u.mutation.ResetProcessCode() + _u.mutation.SetProcessCode(v) + return _u +} + +// SetNillableProcessCode sets the "processCode" field if the given value is not nil. +func (_u *BomItemUpdateOne) SetNillableProcessCode(v *int) *BomItemUpdateOne { + if v != nil { + _u.SetProcessCode(*v) + } + return _u +} + +// AddProcessCode adds value to the "processCode" field. +func (_u *BomItemUpdateOne) AddProcessCode(v int) *BomItemUpdateOne { + _u.mutation.AddProcessCode(v) + return _u +} + // SetUnitQty sets the "unitQty" field. func (_u *BomItemUpdateOne) SetUnitQty(v float64) *BomItemUpdateOne { _u.mutation.ResetUnitQty() @@ -646,6 +694,12 @@ func (_u *BomItemUpdateOne) sqlSave(ctx context.Context) (_node *BomItem, err er if value, ok := _u.mutation.ManageMode(); ok { _spec.SetField(bomitem.FieldManageMode, field.TypeString, value) } + if value, ok := _u.mutation.ProcessCode(); ok { + _spec.SetField(bomitem.FieldProcessCode, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProcessCode(); ok { + _spec.AddField(bomitem.FieldProcessCode, field.TypeInt, value) + } if value, ok := _u.mutation.UnitQty(); ok { _spec.SetField(bomitem.FieldUnitQty, field.TypeFloat64, value) } diff --git a/bj_power_mes/ent/client.go b/bj_power_mes/ent/client.go index cdaa1a3..0447691 100644 --- a/bj_power_mes/ent/client.go +++ b/bj_power_mes/ent/client.go @@ -34,6 +34,7 @@ import ( "bj_power_mes/ent/userstation" "bj_power_mes/ent/workorder" "bj_power_mes/ent/workpiece" + "bj_power_mes/ent/workpiecebind" "bj_power_mes/ent/workpieceprocess" "entgo.io/ent" @@ -94,6 +95,8 @@ type Client struct { WorkOrder *WorkOrderClient // Workpiece is the client for interacting with the Workpiece builders. Workpiece *WorkpieceClient + // WorkpieceBind is the client for interacting with the WorkpieceBind builders. + WorkpieceBind *WorkpieceBindClient // WorkpieceProcess is the client for interacting with the WorkpieceProcess builders. WorkpieceProcess *WorkpieceProcessClient } @@ -130,6 +133,7 @@ func (c *Client) init() { c.UserStation = NewUserStationClient(c.config) c.WorkOrder = NewWorkOrderClient(c.config) c.Workpiece = NewWorkpieceClient(c.config) + c.WorkpieceBind = NewWorkpieceBindClient(c.config) c.WorkpieceProcess = NewWorkpieceProcessClient(c.config) } @@ -246,6 +250,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { UserStation: NewUserStationClient(cfg), WorkOrder: NewWorkOrderClient(cfg), Workpiece: NewWorkpieceClient(cfg), + WorkpieceBind: NewWorkpieceBindClient(cfg), WorkpieceProcess: NewWorkpieceProcessClient(cfg), }, nil } @@ -289,6 +294,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) UserStation: NewUserStationClient(cfg), WorkOrder: NewWorkOrderClient(cfg), Workpiece: NewWorkpieceClient(cfg), + WorkpieceBind: NewWorkpieceBindClient(cfg), WorkpieceProcess: NewWorkpieceProcessClient(cfg), }, nil } @@ -323,7 +329,7 @@ func (c *Client) Use(hooks ...Hook) { c.MaterialRequest, c.Permission, c.PlcSendLog, c.ProcessFlow, c.ProcessStep, c.ProductType, c.Role, c.ScanRecord, c.SemiFlow, c.Station, c.StationProcess, c.StepCriterion, c.StepData, c.TorqueRecord, c.User, c.UserStation, - c.WorkOrder, c.Workpiece, c.WorkpieceProcess, + c.WorkOrder, c.Workpiece, c.WorkpieceBind, c.WorkpieceProcess, } { n.Use(hooks...) } @@ -337,7 +343,7 @@ func (c *Client) Intercept(interceptors ...Interceptor) { c.MaterialRequest, c.Permission, c.PlcSendLog, c.ProcessFlow, c.ProcessStep, c.ProductType, c.Role, c.ScanRecord, c.SemiFlow, c.Station, c.StationProcess, c.StepCriterion, c.StepData, c.TorqueRecord, c.User, c.UserStation, - c.WorkOrder, c.Workpiece, c.WorkpieceProcess, + c.WorkOrder, c.Workpiece, c.WorkpieceBind, c.WorkpieceProcess, } { n.Intercept(interceptors...) } @@ -392,6 +398,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.WorkOrder.mutate(ctx, m) case *WorkpieceMutation: return c.Workpiece.mutate(ctx, m) + case *WorkpieceBindMutation: + return c.WorkpieceBind.mutate(ctx, m) case *WorkpieceProcessMutation: return c.WorkpieceProcess.mutate(ctx, m) default: @@ -3458,6 +3466,139 @@ func (c *WorkpieceClient) mutate(ctx context.Context, m *WorkpieceMutation) (Val } } +// WorkpieceBindClient is a client for the WorkpieceBind schema. +type WorkpieceBindClient struct { + config +} + +// NewWorkpieceBindClient returns a client for the WorkpieceBind from the given config. +func NewWorkpieceBindClient(c config) *WorkpieceBindClient { + return &WorkpieceBindClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `workpiecebind.Hooks(f(g(h())))`. +func (c *WorkpieceBindClient) Use(hooks ...Hook) { + c.hooks.WorkpieceBind = append(c.hooks.WorkpieceBind, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `workpiecebind.Intercept(f(g(h())))`. +func (c *WorkpieceBindClient) Intercept(interceptors ...Interceptor) { + c.inters.WorkpieceBind = append(c.inters.WorkpieceBind, interceptors...) +} + +// Create returns a builder for creating a WorkpieceBind entity. +func (c *WorkpieceBindClient) Create() *WorkpieceBindCreate { + mutation := newWorkpieceBindMutation(c.config, OpCreate) + return &WorkpieceBindCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of WorkpieceBind entities. +func (c *WorkpieceBindClient) CreateBulk(builders ...*WorkpieceBindCreate) *WorkpieceBindCreateBulk { + return &WorkpieceBindCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WorkpieceBindClient) MapCreateBulk(slice any, setFunc func(*WorkpieceBindCreate, int)) *WorkpieceBindCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WorkpieceBindCreateBulk{err: fmt.Errorf("calling to WorkpieceBindClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WorkpieceBindCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WorkpieceBindCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for WorkpieceBind. +func (c *WorkpieceBindClient) Update() *WorkpieceBindUpdate { + mutation := newWorkpieceBindMutation(c.config, OpUpdate) + return &WorkpieceBindUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *WorkpieceBindClient) UpdateOne(_m *WorkpieceBind) *WorkpieceBindUpdateOne { + mutation := newWorkpieceBindMutation(c.config, OpUpdateOne, withWorkpieceBind(_m)) + return &WorkpieceBindUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *WorkpieceBindClient) UpdateOneID(id int) *WorkpieceBindUpdateOne { + mutation := newWorkpieceBindMutation(c.config, OpUpdateOne, withWorkpieceBindID(id)) + return &WorkpieceBindUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for WorkpieceBind. +func (c *WorkpieceBindClient) Delete() *WorkpieceBindDelete { + mutation := newWorkpieceBindMutation(c.config, OpDelete) + return &WorkpieceBindDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *WorkpieceBindClient) DeleteOne(_m *WorkpieceBind) *WorkpieceBindDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *WorkpieceBindClient) DeleteOneID(id int) *WorkpieceBindDeleteOne { + builder := c.Delete().Where(workpiecebind.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &WorkpieceBindDeleteOne{builder} +} + +// Query returns a query builder for WorkpieceBind. +func (c *WorkpieceBindClient) Query() *WorkpieceBindQuery { + return &WorkpieceBindQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeWorkpieceBind}, + inters: c.Interceptors(), + } +} + +// Get returns a WorkpieceBind entity by its id. +func (c *WorkpieceBindClient) Get(ctx context.Context, id int) (*WorkpieceBind, error) { + return c.Query().Where(workpiecebind.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *WorkpieceBindClient) GetX(ctx context.Context, id int) *WorkpieceBind { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *WorkpieceBindClient) Hooks() []Hook { + return c.hooks.WorkpieceBind +} + +// Interceptors returns the client interceptors. +func (c *WorkpieceBindClient) Interceptors() []Interceptor { + return c.inters.WorkpieceBind +} + +func (c *WorkpieceBindClient) mutate(ctx context.Context, m *WorkpieceBindMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&WorkpieceBindCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&WorkpieceBindUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&WorkpieceBindUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&WorkpieceBindDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown WorkpieceBind mutation op: %q", m.Op()) + } +} + // WorkpieceProcessClient is a client for the WorkpieceProcess schema. type WorkpieceProcessClient struct { config @@ -3597,14 +3738,14 @@ type ( AssociationTrace, BomItem, DailyPlan, EventLog, InspectionRecord, MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, ProductType, Role, ScanRecord, SemiFlow, Station, StationProcess, StepCriterion, StepData, - TorqueRecord, User, UserStation, WorkOrder, Workpiece, + TorqueRecord, User, UserStation, WorkOrder, Workpiece, WorkpieceBind, WorkpieceProcess []ent.Hook } inters struct { AssociationTrace, BomItem, DailyPlan, EventLog, InspectionRecord, MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, ProductType, Role, ScanRecord, SemiFlow, Station, StationProcess, StepCriterion, StepData, - TorqueRecord, User, UserStation, WorkOrder, Workpiece, + TorqueRecord, User, UserStation, WorkOrder, Workpiece, WorkpieceBind, WorkpieceProcess []ent.Interceptor } ) diff --git a/bj_power_mes/ent/ent.go b/bj_power_mes/ent/ent.go index 67e859d..91461fc 100644 --- a/bj_power_mes/ent/ent.go +++ b/bj_power_mes/ent/ent.go @@ -26,6 +26,7 @@ import ( "bj_power_mes/ent/userstation" "bj_power_mes/ent/workorder" "bj_power_mes/ent/workpiece" + "bj_power_mes/ent/workpiecebind" "bj_power_mes/ent/workpieceprocess" "context" "errors" @@ -119,6 +120,7 @@ func checkColumn(t, c string) error { userstation.Table: userstation.ValidColumn, workorder.Table: workorder.ValidColumn, workpiece.Table: workpiece.ValidColumn, + workpiecebind.Table: workpiecebind.ValidColumn, workpieceprocess.Table: workpieceprocess.ValidColumn, }) }) diff --git a/bj_power_mes/ent/hook/hook.go b/bj_power_mes/ent/hook/hook.go index a0639fb..49ae122 100644 --- a/bj_power_mes/ent/hook/hook.go +++ b/bj_power_mes/ent/hook/hook.go @@ -284,6 +284,18 @@ func (f WorkpieceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, e return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WorkpieceMutation", m) } +// The WorkpieceBindFunc type is an adapter to allow the use of ordinary +// function as WorkpieceBind mutator. +type WorkpieceBindFunc func(context.Context, *ent.WorkpieceBindMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f WorkpieceBindFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.WorkpieceBindMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WorkpieceBindMutation", m) +} + // The WorkpieceProcessFunc type is an adapter to allow the use of ordinary // function as WorkpieceProcess mutator. type WorkpieceProcessFunc func(context.Context, *ent.WorkpieceProcessMutation) (ent.Value, error) diff --git a/bj_power_mes/ent/migrate/schema.go b/bj_power_mes/ent/migrate/schema.go index 4377e7e..25b42c9 100644 --- a/bj_power_mes/ent/migrate/schema.go +++ b/bj_power_mes/ent/migrate/schema.go @@ -42,6 +42,7 @@ var ( {Name: "spec", Type: field.TypeString, Size: 128, Default: ""}, {Name: "unit", Type: field.TypeString, Size: 16, Default: ""}, {Name: "manage_mode", Type: field.TypeString, Size: 10, Default: "2"}, + {Name: "process_code", Type: field.TypeInt, Default: 0}, {Name: "unit_qty", Type: field.TypeFloat64, Default: 0}, {Name: "loss_rate", Type: field.TypeFloat64, Default: 0}, {Name: "required_qty", Type: field.TypeFloat64, Default: 0}, @@ -231,6 +232,7 @@ var ( {Name: "code", Type: field.TypeString, Unique: true, Size: 64}, {Name: "name", Type: field.TypeString, Size: 64}, {Name: "type", Type: field.TypeString, Size: 20, Default: "MENU"}, + {Name: "parent_code", Type: field.TypeString, Size: 64, Default: ""}, {Name: "path", Type: field.TypeString, Size: 128, Default: ""}, {Name: "icon", Type: field.TypeString, Size: 64, Default: ""}, {Name: "sort", Type: field.TypeInt, Nullable: true, Default: 0}, @@ -775,6 +777,56 @@ var ( }, }, } + // WorkpieceBindColumns holds the columns for the "workpiece_bind" table. + WorkpieceBindColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "sn", Type: field.TypeString, Size: 64}, + {Name: "order_no", Type: field.TypeString, Size: 64, Default: ""}, + {Name: "process_code", Type: field.TypeInt}, + {Name: "station_no", Type: field.TypeString, Size: 32, Default: ""}, + {Name: "material_code", Type: field.TypeString, Size: 64}, + {Name: "material_name", Type: field.TypeString, Size: 128, Default: ""}, + {Name: "spec", Type: field.TypeString, Size: 128, Default: ""}, + {Name: "unit", Type: field.TypeString, Size: 16, Default: ""}, + {Name: "manage_mode", Type: field.TypeString, Size: 10, Default: "2"}, + {Name: "bind_value", Type: field.TypeString, Size: 128}, + {Name: "bind_type", Type: field.TypeString, Size: 10, Default: "SN"}, + {Name: "operator", Type: field.TypeString, Size: 64, Default: ""}, + {Name: "created_at", Type: field.TypeTime}, + } + // WorkpieceBindTable holds the schema information for the "workpiece_bind" table. + WorkpieceBindTable = &schema.Table{ + Name: "workpiece_bind", + Columns: WorkpieceBindColumns, + PrimaryKey: []*schema.Column{WorkpieceBindColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "workpiecebind_sn", + Unique: false, + Columns: []*schema.Column{WorkpieceBindColumns[1]}, + }, + { + Name: "workpiecebind_sn_process_code", + Unique: false, + Columns: []*schema.Column{WorkpieceBindColumns[1], WorkpieceBindColumns[3]}, + }, + { + Name: "workpiecebind_sn_material_code", + Unique: false, + Columns: []*schema.Column{WorkpieceBindColumns[1], WorkpieceBindColumns[5]}, + }, + { + Name: "workpiecebind_order_no", + Unique: false, + Columns: []*schema.Column{WorkpieceBindColumns[2]}, + }, + { + Name: "workpiecebind_material_code_bind_value", + Unique: false, + Columns: []*schema.Column{WorkpieceBindColumns[5], WorkpieceBindColumns[10]}, + }, + }, + } // WorkpieceProcessColumns holds the columns for the "workpiece_process" table. WorkpieceProcessColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -844,6 +896,7 @@ var ( UserStationTable, WorkOrderTable, WorkpieceTable, + WorkpieceBindTable, WorkpieceProcessTable, } ) @@ -918,6 +971,9 @@ func init() { WorkpieceTable.Annotation = &entsql.Annotation{ Table: "workpiece", } + WorkpieceBindTable.Annotation = &entsql.Annotation{ + Table: "workpiece_bind", + } WorkpieceProcessTable.Annotation = &entsql.Annotation{ Table: "workpiece_process", } diff --git a/bj_power_mes/ent/mutation.go b/bj_power_mes/ent/mutation.go index 6bed5b8..c47dd05 100644 --- a/bj_power_mes/ent/mutation.go +++ b/bj_power_mes/ent/mutation.go @@ -27,6 +27,7 @@ import ( "bj_power_mes/ent/userstation" "bj_power_mes/ent/workorder" "bj_power_mes/ent/workpiece" + "bj_power_mes/ent/workpiecebind" "bj_power_mes/ent/workpieceprocess" "context" "errors" @@ -70,6 +71,7 @@ const ( TypeUserStation = "UserStation" TypeWorkOrder = "WorkOrder" TypeWorkpiece = "Workpiece" + TypeWorkpieceBind = "WorkpieceBind" TypeWorkpieceProcess = "WorkpieceProcess" ) @@ -816,6 +818,8 @@ type BomItemMutation struct { spec *string unit *string manageMode *string + processCode *int + addprocessCode *int unitQty *float64 addunitQty *float64 lossRate *float64 @@ -1151,6 +1155,62 @@ func (m *BomItemMutation) ResetManageMode() { m.manageMode = nil } +// SetProcessCode sets the "processCode" field. +func (m *BomItemMutation) SetProcessCode(i int) { + m.processCode = &i + m.addprocessCode = nil +} + +// ProcessCode returns the value of the "processCode" field in the mutation. +func (m *BomItemMutation) ProcessCode() (r int, exists bool) { + v := m.processCode + if v == nil { + return + } + return *v, true +} + +// OldProcessCode returns the old "processCode" field's value of the BomItem entity. +// If the BomItem object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BomItemMutation) OldProcessCode(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProcessCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProcessCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProcessCode: %w", err) + } + return oldValue.ProcessCode, nil +} + +// AddProcessCode adds i to the "processCode" field. +func (m *BomItemMutation) AddProcessCode(i int) { + if m.addprocessCode != nil { + *m.addprocessCode += i + } else { + m.addprocessCode = &i + } +} + +// AddedProcessCode returns the value that was added to the "processCode" field in this mutation. +func (m *BomItemMutation) AddedProcessCode() (r int, exists bool) { + v := m.addprocessCode + if v == nil { + return + } + return *v, true +} + +// ResetProcessCode resets all changes to the "processCode" field. +func (m *BomItemMutation) ResetProcessCode() { + m.processCode = nil + m.addprocessCode = nil +} + // SetUnitQty sets the "unitQty" field. func (m *BomItemMutation) SetUnitQty(f float64) { m.unitQty = &f @@ -1454,7 +1514,7 @@ func (m *BomItemMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BomItemMutation) Fields() []string { - fields := make([]string, 0, 11) + fields := make([]string, 0, 12) if m.productCode != nil { fields = append(fields, bomitem.FieldProductCode) } @@ -1473,6 +1533,9 @@ func (m *BomItemMutation) Fields() []string { if m.manageMode != nil { fields = append(fields, bomitem.FieldManageMode) } + if m.processCode != nil { + fields = append(fields, bomitem.FieldProcessCode) + } if m.unitQty != nil { fields = append(fields, bomitem.FieldUnitQty) } @@ -1508,6 +1571,8 @@ func (m *BomItemMutation) Field(name string) (ent.Value, bool) { return m.Unit() case bomitem.FieldManageMode: return m.ManageMode() + case bomitem.FieldProcessCode: + return m.ProcessCode() case bomitem.FieldUnitQty: return m.UnitQty() case bomitem.FieldLossRate: @@ -1539,6 +1604,8 @@ func (m *BomItemMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldUnit(ctx) case bomitem.FieldManageMode: return m.OldManageMode(ctx) + case bomitem.FieldProcessCode: + return m.OldProcessCode(ctx) case bomitem.FieldUnitQty: return m.OldUnitQty(ctx) case bomitem.FieldLossRate: @@ -1600,6 +1667,13 @@ func (m *BomItemMutation) SetField(name string, value ent.Value) error { } m.SetManageMode(v) return nil + case bomitem.FieldProcessCode: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProcessCode(v) + return nil case bomitem.FieldUnitQty: v, ok := value.(float64) if !ok { @@ -1643,6 +1717,9 @@ func (m *BomItemMutation) SetField(name string, value ent.Value) error { // this mutation. func (m *BomItemMutation) AddedFields() []string { var fields []string + if m.addprocessCode != nil { + fields = append(fields, bomitem.FieldProcessCode) + } if m.addunitQty != nil { fields = append(fields, bomitem.FieldUnitQty) } @@ -1660,6 +1737,8 @@ func (m *BomItemMutation) AddedFields() []string { // was not set, or was not defined in the schema. func (m *BomItemMutation) AddedField(name string) (ent.Value, bool) { switch name { + case bomitem.FieldProcessCode: + return m.AddedProcessCode() case bomitem.FieldUnitQty: return m.AddedUnitQty() case bomitem.FieldLossRate: @@ -1675,6 +1754,13 @@ func (m *BomItemMutation) AddedField(name string) (ent.Value, bool) { // type. func (m *BomItemMutation) AddField(name string, value ent.Value) error { switch name { + case bomitem.FieldProcessCode: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddProcessCode(v) + return nil case bomitem.FieldUnitQty: v, ok := value.(float64) if !ok { @@ -1750,6 +1836,9 @@ func (m *BomItemMutation) ResetField(name string) error { case bomitem.FieldManageMode: m.ResetManageMode() return nil + case bomitem.FieldProcessCode: + m.ResetProcessCode() + return nil case bomitem.FieldUnitQty: m.ResetUnitQty() return nil @@ -5398,6 +5487,7 @@ type PermissionMutation struct { code *string name *string _type *string + parentCode *string _path *string icon *string sort *int @@ -5622,6 +5712,42 @@ func (m *PermissionMutation) ResetType() { m._type = nil } +// SetParentCode sets the "parentCode" field. +func (m *PermissionMutation) SetParentCode(s string) { + m.parentCode = &s +} + +// ParentCode returns the value of the "parentCode" field in the mutation. +func (m *PermissionMutation) ParentCode() (r string, exists bool) { + v := m.parentCode + if v == nil { + return + } + return *v, true +} + +// OldParentCode returns the old "parentCode" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldParentCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParentCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParentCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParentCode: %w", err) + } + return oldValue.ParentCode, nil +} + +// ResetParentCode resets all changes to the "parentCode" field. +func (m *PermissionMutation) ResetParentCode() { + m.parentCode = nil +} + // SetPath sets the "path" field. func (m *PermissionMutation) SetPath(s string) { m._path = &s @@ -5870,7 +5996,7 @@ func (m *PermissionMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PermissionMutation) Fields() []string { - fields := make([]string, 0, 8) + fields := make([]string, 0, 9) if m.code != nil { fields = append(fields, permission.FieldCode) } @@ -5880,6 +6006,9 @@ func (m *PermissionMutation) Fields() []string { if m._type != nil { fields = append(fields, permission.FieldType) } + if m.parentCode != nil { + fields = append(fields, permission.FieldParentCode) + } if m._path != nil { fields = append(fields, permission.FieldPath) } @@ -5909,6 +6038,8 @@ func (m *PermissionMutation) Field(name string) (ent.Value, bool) { return m.Name() case permission.FieldType: return m.GetType() + case permission.FieldParentCode: + return m.ParentCode() case permission.FieldPath: return m.Path() case permission.FieldIcon: @@ -5934,6 +6065,8 @@ func (m *PermissionMutation) OldField(ctx context.Context, name string) (ent.Val return m.OldName(ctx) case permission.FieldType: return m.OldType(ctx) + case permission.FieldParentCode: + return m.OldParentCode(ctx) case permission.FieldPath: return m.OldPath(ctx) case permission.FieldIcon: @@ -5974,6 +6107,13 @@ func (m *PermissionMutation) SetField(name string, value ent.Value) error { } m.SetType(v) return nil + case permission.FieldParentCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParentCode(v) + return nil case permission.FieldPath: v, ok := value.(string) if !ok { @@ -6091,6 +6231,9 @@ func (m *PermissionMutation) ResetField(name string) error { case permission.FieldType: m.ResetType() return nil + case permission.FieldParentCode: + m.ResetParentCode() + return nil case permission.FieldPath: m.ResetPath() return nil @@ -19450,6 +19593,1022 @@ func (m *WorkpieceMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Workpiece edge %s", name) } +// WorkpieceBindMutation represents an operation that mutates the WorkpieceBind nodes in the graph. +type WorkpieceBindMutation struct { + config + op Op + typ string + id *int + sn *string + orderNo *string + processCode *int + addprocessCode *int + stationNo *string + materialCode *string + materialName *string + spec *string + unit *string + manageMode *string + bindValue *string + bindType *string + operator *string + createdAt *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*WorkpieceBind, error) + predicates []predicate.WorkpieceBind +} + +var _ ent.Mutation = (*WorkpieceBindMutation)(nil) + +// workpiecebindOption allows management of the mutation configuration using functional options. +type workpiecebindOption func(*WorkpieceBindMutation) + +// newWorkpieceBindMutation creates new mutation for the WorkpieceBind entity. +func newWorkpieceBindMutation(c config, op Op, opts ...workpiecebindOption) *WorkpieceBindMutation { + m := &WorkpieceBindMutation{ + config: c, + op: op, + typ: TypeWorkpieceBind, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withWorkpieceBindID sets the ID field of the mutation. +func withWorkpieceBindID(id int) workpiecebindOption { + return func(m *WorkpieceBindMutation) { + var ( + err error + once sync.Once + value *WorkpieceBind + ) + m.oldValue = func(ctx context.Context) (*WorkpieceBind, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().WorkpieceBind.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withWorkpieceBind sets the old WorkpieceBind of the mutation. +func withWorkpieceBind(node *WorkpieceBind) workpiecebindOption { + return func(m *WorkpieceBindMutation) { + m.oldValue = func(context.Context) (*WorkpieceBind, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m WorkpieceBindMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m WorkpieceBindMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of WorkpieceBind entities. +func (m *WorkpieceBindMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *WorkpieceBindMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *WorkpieceBindMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().WorkpieceBind.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetSn sets the "sn" field. +func (m *WorkpieceBindMutation) SetSn(s string) { + m.sn = &s +} + +// Sn returns the value of the "sn" field in the mutation. +func (m *WorkpieceBindMutation) Sn() (r string, exists bool) { + v := m.sn + if v == nil { + return + } + return *v, true +} + +// OldSn returns the old "sn" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldSn(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSn is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSn requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSn: %w", err) + } + return oldValue.Sn, nil +} + +// ResetSn resets all changes to the "sn" field. +func (m *WorkpieceBindMutation) ResetSn() { + m.sn = nil +} + +// SetOrderNo sets the "orderNo" field. +func (m *WorkpieceBindMutation) SetOrderNo(s string) { + m.orderNo = &s +} + +// OrderNo returns the value of the "orderNo" field in the mutation. +func (m *WorkpieceBindMutation) OrderNo() (r string, exists bool) { + v := m.orderNo + if v == nil { + return + } + return *v, true +} + +// OldOrderNo returns the old "orderNo" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldOrderNo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrderNo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrderNo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrderNo: %w", err) + } + return oldValue.OrderNo, nil +} + +// ResetOrderNo resets all changes to the "orderNo" field. +func (m *WorkpieceBindMutation) ResetOrderNo() { + m.orderNo = nil +} + +// SetProcessCode sets the "processCode" field. +func (m *WorkpieceBindMutation) SetProcessCode(i int) { + m.processCode = &i + m.addprocessCode = nil +} + +// ProcessCode returns the value of the "processCode" field in the mutation. +func (m *WorkpieceBindMutation) ProcessCode() (r int, exists bool) { + v := m.processCode + if v == nil { + return + } + return *v, true +} + +// OldProcessCode returns the old "processCode" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldProcessCode(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProcessCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProcessCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProcessCode: %w", err) + } + return oldValue.ProcessCode, nil +} + +// AddProcessCode adds i to the "processCode" field. +func (m *WorkpieceBindMutation) AddProcessCode(i int) { + if m.addprocessCode != nil { + *m.addprocessCode += i + } else { + m.addprocessCode = &i + } +} + +// AddedProcessCode returns the value that was added to the "processCode" field in this mutation. +func (m *WorkpieceBindMutation) AddedProcessCode() (r int, exists bool) { + v := m.addprocessCode + if v == nil { + return + } + return *v, true +} + +// ResetProcessCode resets all changes to the "processCode" field. +func (m *WorkpieceBindMutation) ResetProcessCode() { + m.processCode = nil + m.addprocessCode = nil +} + +// SetStationNo sets the "stationNo" field. +func (m *WorkpieceBindMutation) SetStationNo(s string) { + m.stationNo = &s +} + +// StationNo returns the value of the "stationNo" field in the mutation. +func (m *WorkpieceBindMutation) StationNo() (r string, exists bool) { + v := m.stationNo + if v == nil { + return + } + return *v, true +} + +// OldStationNo returns the old "stationNo" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldStationNo(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStationNo is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStationNo requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStationNo: %w", err) + } + return oldValue.StationNo, nil +} + +// ResetStationNo resets all changes to the "stationNo" field. +func (m *WorkpieceBindMutation) ResetStationNo() { + m.stationNo = nil +} + +// SetMaterialCode sets the "materialCode" field. +func (m *WorkpieceBindMutation) SetMaterialCode(s string) { + m.materialCode = &s +} + +// MaterialCode returns the value of the "materialCode" field in the mutation. +func (m *WorkpieceBindMutation) MaterialCode() (r string, exists bool) { + v := m.materialCode + if v == nil { + return + } + return *v, true +} + +// OldMaterialCode returns the old "materialCode" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldMaterialCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMaterialCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMaterialCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMaterialCode: %w", err) + } + return oldValue.MaterialCode, nil +} + +// ResetMaterialCode resets all changes to the "materialCode" field. +func (m *WorkpieceBindMutation) ResetMaterialCode() { + m.materialCode = nil +} + +// SetMaterialName sets the "materialName" field. +func (m *WorkpieceBindMutation) SetMaterialName(s string) { + m.materialName = &s +} + +// MaterialName returns the value of the "materialName" field in the mutation. +func (m *WorkpieceBindMutation) MaterialName() (r string, exists bool) { + v := m.materialName + if v == nil { + return + } + return *v, true +} + +// OldMaterialName returns the old "materialName" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldMaterialName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMaterialName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMaterialName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMaterialName: %w", err) + } + return oldValue.MaterialName, nil +} + +// ResetMaterialName resets all changes to the "materialName" field. +func (m *WorkpieceBindMutation) ResetMaterialName() { + m.materialName = nil +} + +// SetSpec sets the "spec" field. +func (m *WorkpieceBindMutation) SetSpec(s string) { + m.spec = &s +} + +// Spec returns the value of the "spec" field in the mutation. +func (m *WorkpieceBindMutation) Spec() (r string, exists bool) { + v := m.spec + if v == nil { + return + } + return *v, true +} + +// OldSpec returns the old "spec" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldSpec(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSpec is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSpec requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSpec: %w", err) + } + return oldValue.Spec, nil +} + +// ResetSpec resets all changes to the "spec" field. +func (m *WorkpieceBindMutation) ResetSpec() { + m.spec = nil +} + +// SetUnit sets the "unit" field. +func (m *WorkpieceBindMutation) SetUnit(s string) { + m.unit = &s +} + +// Unit returns the value of the "unit" field in the mutation. +func (m *WorkpieceBindMutation) Unit() (r string, exists bool) { + v := m.unit + if v == nil { + return + } + return *v, true +} + +// OldUnit returns the old "unit" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldUnit(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUnit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUnit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUnit: %w", err) + } + return oldValue.Unit, nil +} + +// ResetUnit resets all changes to the "unit" field. +func (m *WorkpieceBindMutation) ResetUnit() { + m.unit = nil +} + +// SetManageMode sets the "manageMode" field. +func (m *WorkpieceBindMutation) SetManageMode(s string) { + m.manageMode = &s +} + +// ManageMode returns the value of the "manageMode" field in the mutation. +func (m *WorkpieceBindMutation) ManageMode() (r string, exists bool) { + v := m.manageMode + if v == nil { + return + } + return *v, true +} + +// OldManageMode returns the old "manageMode" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldManageMode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldManageMode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldManageMode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldManageMode: %w", err) + } + return oldValue.ManageMode, nil +} + +// ResetManageMode resets all changes to the "manageMode" field. +func (m *WorkpieceBindMutation) ResetManageMode() { + m.manageMode = nil +} + +// SetBindValue sets the "bindValue" field. +func (m *WorkpieceBindMutation) SetBindValue(s string) { + m.bindValue = &s +} + +// BindValue returns the value of the "bindValue" field in the mutation. +func (m *WorkpieceBindMutation) BindValue() (r string, exists bool) { + v := m.bindValue + if v == nil { + return + } + return *v, true +} + +// OldBindValue returns the old "bindValue" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldBindValue(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBindValue is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBindValue requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBindValue: %w", err) + } + return oldValue.BindValue, nil +} + +// ResetBindValue resets all changes to the "bindValue" field. +func (m *WorkpieceBindMutation) ResetBindValue() { + m.bindValue = nil +} + +// SetBindType sets the "bindType" field. +func (m *WorkpieceBindMutation) SetBindType(s string) { + m.bindType = &s +} + +// BindType returns the value of the "bindType" field in the mutation. +func (m *WorkpieceBindMutation) BindType() (r string, exists bool) { + v := m.bindType + if v == nil { + return + } + return *v, true +} + +// OldBindType returns the old "bindType" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldBindType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBindType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBindType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBindType: %w", err) + } + return oldValue.BindType, nil +} + +// ResetBindType resets all changes to the "bindType" field. +func (m *WorkpieceBindMutation) ResetBindType() { + m.bindType = nil +} + +// SetOperator sets the "operator" field. +func (m *WorkpieceBindMutation) SetOperator(s string) { + m.operator = &s +} + +// Operator returns the value of the "operator" field in the mutation. +func (m *WorkpieceBindMutation) Operator() (r string, exists bool) { + v := m.operator + if v == nil { + return + } + return *v, true +} + +// OldOperator returns the old "operator" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldOperator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOperator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOperator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOperator: %w", err) + } + return oldValue.Operator, nil +} + +// ResetOperator resets all changes to the "operator" field. +func (m *WorkpieceBindMutation) ResetOperator() { + m.operator = nil +} + +// SetCreatedAt sets the "createdAt" field. +func (m *WorkpieceBindMutation) SetCreatedAt(t time.Time) { + m.createdAt = &t +} + +// CreatedAt returns the value of the "createdAt" field in the mutation. +func (m *WorkpieceBindMutation) CreatedAt() (r time.Time, exists bool) { + v := m.createdAt + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "createdAt" field's value of the WorkpieceBind entity. +// If the WorkpieceBind object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkpieceBindMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "createdAt" field. +func (m *WorkpieceBindMutation) ResetCreatedAt() { + m.createdAt = nil +} + +// Where appends a list predicates to the WorkpieceBindMutation builder. +func (m *WorkpieceBindMutation) Where(ps ...predicate.WorkpieceBind) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the WorkpieceBindMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *WorkpieceBindMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.WorkpieceBind, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *WorkpieceBindMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *WorkpieceBindMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (WorkpieceBind). +func (m *WorkpieceBindMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *WorkpieceBindMutation) Fields() []string { + fields := make([]string, 0, 13) + if m.sn != nil { + fields = append(fields, workpiecebind.FieldSn) + } + if m.orderNo != nil { + fields = append(fields, workpiecebind.FieldOrderNo) + } + if m.processCode != nil { + fields = append(fields, workpiecebind.FieldProcessCode) + } + if m.stationNo != nil { + fields = append(fields, workpiecebind.FieldStationNo) + } + if m.materialCode != nil { + fields = append(fields, workpiecebind.FieldMaterialCode) + } + if m.materialName != nil { + fields = append(fields, workpiecebind.FieldMaterialName) + } + if m.spec != nil { + fields = append(fields, workpiecebind.FieldSpec) + } + if m.unit != nil { + fields = append(fields, workpiecebind.FieldUnit) + } + if m.manageMode != nil { + fields = append(fields, workpiecebind.FieldManageMode) + } + if m.bindValue != nil { + fields = append(fields, workpiecebind.FieldBindValue) + } + if m.bindType != nil { + fields = append(fields, workpiecebind.FieldBindType) + } + if m.operator != nil { + fields = append(fields, workpiecebind.FieldOperator) + } + if m.createdAt != nil { + fields = append(fields, workpiecebind.FieldCreatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *WorkpieceBindMutation) Field(name string) (ent.Value, bool) { + switch name { + case workpiecebind.FieldSn: + return m.Sn() + case workpiecebind.FieldOrderNo: + return m.OrderNo() + case workpiecebind.FieldProcessCode: + return m.ProcessCode() + case workpiecebind.FieldStationNo: + return m.StationNo() + case workpiecebind.FieldMaterialCode: + return m.MaterialCode() + case workpiecebind.FieldMaterialName: + return m.MaterialName() + case workpiecebind.FieldSpec: + return m.Spec() + case workpiecebind.FieldUnit: + return m.Unit() + case workpiecebind.FieldManageMode: + return m.ManageMode() + case workpiecebind.FieldBindValue: + return m.BindValue() + case workpiecebind.FieldBindType: + return m.BindType() + case workpiecebind.FieldOperator: + return m.Operator() + case workpiecebind.FieldCreatedAt: + return m.CreatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *WorkpieceBindMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case workpiecebind.FieldSn: + return m.OldSn(ctx) + case workpiecebind.FieldOrderNo: + return m.OldOrderNo(ctx) + case workpiecebind.FieldProcessCode: + return m.OldProcessCode(ctx) + case workpiecebind.FieldStationNo: + return m.OldStationNo(ctx) + case workpiecebind.FieldMaterialCode: + return m.OldMaterialCode(ctx) + case workpiecebind.FieldMaterialName: + return m.OldMaterialName(ctx) + case workpiecebind.FieldSpec: + return m.OldSpec(ctx) + case workpiecebind.FieldUnit: + return m.OldUnit(ctx) + case workpiecebind.FieldManageMode: + return m.OldManageMode(ctx) + case workpiecebind.FieldBindValue: + return m.OldBindValue(ctx) + case workpiecebind.FieldBindType: + return m.OldBindType(ctx) + case workpiecebind.FieldOperator: + return m.OldOperator(ctx) + case workpiecebind.FieldCreatedAt: + return m.OldCreatedAt(ctx) + } + return nil, fmt.Errorf("unknown WorkpieceBind field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WorkpieceBindMutation) SetField(name string, value ent.Value) error { + switch name { + case workpiecebind.FieldSn: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSn(v) + return nil + case workpiecebind.FieldOrderNo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrderNo(v) + return nil + case workpiecebind.FieldProcessCode: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProcessCode(v) + return nil + case workpiecebind.FieldStationNo: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStationNo(v) + return nil + case workpiecebind.FieldMaterialCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMaterialCode(v) + return nil + case workpiecebind.FieldMaterialName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMaterialName(v) + return nil + case workpiecebind.FieldSpec: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpec(v) + return nil + case workpiecebind.FieldUnit: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUnit(v) + return nil + case workpiecebind.FieldManageMode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetManageMode(v) + return nil + case workpiecebind.FieldBindValue: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBindValue(v) + return nil + case workpiecebind.FieldBindType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBindType(v) + return nil + case workpiecebind.FieldOperator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOperator(v) + return nil + case workpiecebind.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown WorkpieceBind field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *WorkpieceBindMutation) AddedFields() []string { + var fields []string + if m.addprocessCode != nil { + fields = append(fields, workpiecebind.FieldProcessCode) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *WorkpieceBindMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case workpiecebind.FieldProcessCode: + return m.AddedProcessCode() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WorkpieceBindMutation) AddField(name string, value ent.Value) error { + switch name { + case workpiecebind.FieldProcessCode: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddProcessCode(v) + return nil + } + return fmt.Errorf("unknown WorkpieceBind numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *WorkpieceBindMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *WorkpieceBindMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *WorkpieceBindMutation) ClearField(name string) error { + return fmt.Errorf("unknown WorkpieceBind nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *WorkpieceBindMutation) ResetField(name string) error { + switch name { + case workpiecebind.FieldSn: + m.ResetSn() + return nil + case workpiecebind.FieldOrderNo: + m.ResetOrderNo() + return nil + case workpiecebind.FieldProcessCode: + m.ResetProcessCode() + return nil + case workpiecebind.FieldStationNo: + m.ResetStationNo() + return nil + case workpiecebind.FieldMaterialCode: + m.ResetMaterialCode() + return nil + case workpiecebind.FieldMaterialName: + m.ResetMaterialName() + return nil + case workpiecebind.FieldSpec: + m.ResetSpec() + return nil + case workpiecebind.FieldUnit: + m.ResetUnit() + return nil + case workpiecebind.FieldManageMode: + m.ResetManageMode() + return nil + case workpiecebind.FieldBindValue: + m.ResetBindValue() + return nil + case workpiecebind.FieldBindType: + m.ResetBindType() + return nil + case workpiecebind.FieldOperator: + m.ResetOperator() + return nil + case workpiecebind.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown WorkpieceBind field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *WorkpieceBindMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *WorkpieceBindMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *WorkpieceBindMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *WorkpieceBindMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *WorkpieceBindMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *WorkpieceBindMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *WorkpieceBindMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown WorkpieceBind unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *WorkpieceBindMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown WorkpieceBind edge %s", name) +} + // WorkpieceProcessMutation represents an operation that mutates the WorkpieceProcess nodes in the graph. type WorkpieceProcessMutation struct { config diff --git a/bj_power_mes/ent/permission.go b/bj_power_mes/ent/permission.go index cd44002..fd4b9e0 100644 --- a/bj_power_mes/ent/permission.go +++ b/bj_power_mes/ent/permission.go @@ -23,6 +23,8 @@ type Permission struct { Name string `json:"name,omitempty"` // Type holds the value of the "type" field. Type string `json:"type,omitempty"` + // 所属菜单权限码(按钮必填) + ParentCode string `json:"parentCode,omitempty"` // 前端路由 Path string `json:"path,omitempty"` // Icon holds the value of the "icon" field. @@ -43,7 +45,7 @@ func (*Permission) scanValues(columns []string) ([]any, error) { switch columns[i] { case permission.FieldID, permission.FieldSort: values[i] = new(sql.NullInt64) - case permission.FieldCode, permission.FieldName, permission.FieldType, permission.FieldPath, permission.FieldIcon, permission.FieldRemark: + case permission.FieldCode, permission.FieldName, permission.FieldType, permission.FieldParentCode, permission.FieldPath, permission.FieldIcon, permission.FieldRemark: values[i] = new(sql.NullString) case permission.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -86,6 +88,12 @@ func (_m *Permission) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Type = value.String } + case permission.FieldParentCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field parentCode", values[i]) + } else if value.Valid { + _m.ParentCode = value.String + } case permission.FieldPath: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field path", values[i]) @@ -161,6 +169,9 @@ func (_m *Permission) String() string { builder.WriteString("type=") builder.WriteString(_m.Type) builder.WriteString(", ") + builder.WriteString("parentCode=") + builder.WriteString(_m.ParentCode) + builder.WriteString(", ") builder.WriteString("path=") builder.WriteString(_m.Path) builder.WriteString(", ") diff --git a/bj_power_mes/ent/permission/permission.go b/bj_power_mes/ent/permission/permission.go index dc46d17..fb6bf7b 100644 --- a/bj_power_mes/ent/permission/permission.go +++ b/bj_power_mes/ent/permission/permission.go @@ -19,6 +19,8 @@ const ( FieldName = "name" // FieldType holds the string denoting the type field in the database. FieldType = "type" + // FieldParentCode holds the string denoting the parentcode field in the database. + FieldParentCode = "parent_code" // FieldPath holds the string denoting the path field in the database. FieldPath = "path" // FieldIcon holds the string denoting the icon field in the database. @@ -39,6 +41,7 @@ var Columns = []string{ FieldCode, FieldName, FieldType, + FieldParentCode, FieldPath, FieldIcon, FieldSort, @@ -65,6 +68,10 @@ var ( DefaultType string // TypeValidator is a validator for the "type" field. It is called by the builders before save. TypeValidator func(string) error + // DefaultParentCode holds the default value on creation for the "parentCode" field. + DefaultParentCode string + // ParentCodeValidator is a validator for the "parentCode" field. It is called by the builders before save. + ParentCodeValidator func(string) error // DefaultPath holds the default value on creation for the "path" field. DefaultPath string // PathValidator is a validator for the "path" field. It is called by the builders before save. @@ -108,6 +115,11 @@ func ByType(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldType, opts...).ToFunc() } +// ByParentCode orders the results by the parentCode field. +func ByParentCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentCode, opts...).ToFunc() +} + // ByPath orders the results by the path field. func ByPath(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPath, opts...).ToFunc() diff --git a/bj_power_mes/ent/permission/where.go b/bj_power_mes/ent/permission/where.go index 184c791..a33fe26 100644 --- a/bj_power_mes/ent/permission/where.go +++ b/bj_power_mes/ent/permission/where.go @@ -69,6 +69,11 @@ func Type(v string) predicate.Permission { return predicate.Permission(sql.FieldEQ(FieldType, v)) } +// ParentCode applies equality check predicate on the "parentCode" field. It's identical to ParentCodeEQ. +func ParentCode(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldParentCode, v)) +} + // Path applies equality check predicate on the "path" field. It's identical to PathEQ. func Path(v string) predicate.Permission { return predicate.Permission(sql.FieldEQ(FieldPath, v)) @@ -289,6 +294,71 @@ func TypeContainsFold(v string) predicate.Permission { return predicate.Permission(sql.FieldContainsFold(FieldType, v)) } +// ParentCodeEQ applies the EQ predicate on the "parentCode" field. +func ParentCodeEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldParentCode, v)) +} + +// ParentCodeNEQ applies the NEQ predicate on the "parentCode" field. +func ParentCodeNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldParentCode, v)) +} + +// ParentCodeIn applies the In predicate on the "parentCode" field. +func ParentCodeIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldParentCode, vs...)) +} + +// ParentCodeNotIn applies the NotIn predicate on the "parentCode" field. +func ParentCodeNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldParentCode, vs...)) +} + +// ParentCodeGT applies the GT predicate on the "parentCode" field. +func ParentCodeGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldParentCode, v)) +} + +// ParentCodeGTE applies the GTE predicate on the "parentCode" field. +func ParentCodeGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldParentCode, v)) +} + +// ParentCodeLT applies the LT predicate on the "parentCode" field. +func ParentCodeLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldParentCode, v)) +} + +// ParentCodeLTE applies the LTE predicate on the "parentCode" field. +func ParentCodeLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldParentCode, v)) +} + +// ParentCodeContains applies the Contains predicate on the "parentCode" field. +func ParentCodeContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldParentCode, v)) +} + +// ParentCodeHasPrefix applies the HasPrefix predicate on the "parentCode" field. +func ParentCodeHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldParentCode, v)) +} + +// ParentCodeHasSuffix applies the HasSuffix predicate on the "parentCode" field. +func ParentCodeHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldParentCode, v)) +} + +// ParentCodeEqualFold applies the EqualFold predicate on the "parentCode" field. +func ParentCodeEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldParentCode, v)) +} + +// ParentCodeContainsFold applies the ContainsFold predicate on the "parentCode" field. +func ParentCodeContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldParentCode, v)) +} + // PathEQ applies the EQ predicate on the "path" field. func PathEQ(v string) predicate.Permission { return predicate.Permission(sql.FieldEQ(FieldPath, v)) diff --git a/bj_power_mes/ent/permission_create.go b/bj_power_mes/ent/permission_create.go index c31df18..acc1fb0 100644 --- a/bj_power_mes/ent/permission_create.go +++ b/bj_power_mes/ent/permission_create.go @@ -46,6 +46,20 @@ func (_c *PermissionCreate) SetNillableType(v *string) *PermissionCreate { return _c } +// SetParentCode sets the "parentCode" field. +func (_c *PermissionCreate) SetParentCode(v string) *PermissionCreate { + _c.mutation.SetParentCode(v) + return _c +} + +// SetNillableParentCode sets the "parentCode" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableParentCode(v *string) *PermissionCreate { + if v != nil { + _c.SetParentCode(*v) + } + return _c +} + // SetPath sets the "path" field. func (_c *PermissionCreate) SetPath(v string) *PermissionCreate { _c.mutation.SetPath(v) @@ -161,6 +175,10 @@ func (_c *PermissionCreate) defaults() { v := permission.DefaultType _c.mutation.SetType(v) } + if _, ok := _c.mutation.ParentCode(); !ok { + v := permission.DefaultParentCode + _c.mutation.SetParentCode(v) + } if _, ok := _c.mutation.Path(); !ok { v := permission.DefaultPath _c.mutation.SetPath(v) @@ -209,6 +227,14 @@ func (_c *PermissionCreate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Permission.type": %w`, err)} } } + if _, ok := _c.mutation.ParentCode(); !ok { + return &ValidationError{Name: "parentCode", err: errors.New(`ent: missing required field "Permission.parentCode"`)} + } + if v, ok := _c.mutation.ParentCode(); ok { + if err := permission.ParentCodeValidator(v); err != nil { + return &ValidationError{Name: "parentCode", err: fmt.Errorf(`ent: validator failed for field "Permission.parentCode": %w`, err)} + } + } if _, ok := _c.mutation.Path(); !ok { return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Permission.path"`)} } @@ -285,6 +311,10 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { _spec.SetField(permission.FieldType, field.TypeString, value) _node.Type = value } + if value, ok := _c.mutation.ParentCode(); ok { + _spec.SetField(permission.FieldParentCode, field.TypeString, value) + _node.ParentCode = value + } if value, ok := _c.mutation.Path(); ok { _spec.SetField(permission.FieldPath, field.TypeString, value) _node.Path = value diff --git a/bj_power_mes/ent/permission_update.go b/bj_power_mes/ent/permission_update.go index d6e2c0a..c4a5fb2 100644 --- a/bj_power_mes/ent/permission_update.go +++ b/bj_power_mes/ent/permission_update.go @@ -70,6 +70,20 @@ func (_u *PermissionUpdate) SetNillableType(v *string) *PermissionUpdate { return _u } +// SetParentCode sets the "parentCode" field. +func (_u *PermissionUpdate) SetParentCode(v string) *PermissionUpdate { + _u.mutation.SetParentCode(v) + return _u +} + +// SetNillableParentCode sets the "parentCode" field if the given value is not nil. +func (_u *PermissionUpdate) SetNillableParentCode(v *string) *PermissionUpdate { + if v != nil { + _u.SetParentCode(*v) + } + return _u +} + // SetPath sets the "path" field. func (_u *PermissionUpdate) SetPath(v string) *PermissionUpdate { _u.mutation.SetPath(v) @@ -188,6 +202,11 @@ func (_u *PermissionUpdate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Permission.type": %w`, err)} } } + if v, ok := _u.mutation.ParentCode(); ok { + if err := permission.ParentCodeValidator(v); err != nil { + return &ValidationError{Name: "parentCode", err: fmt.Errorf(`ent: validator failed for field "Permission.parentCode": %w`, err)} + } + } if v, ok := _u.mutation.Path(); ok { if err := permission.PathValidator(v); err != nil { return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Permission.path": %w`, err)} @@ -233,6 +252,9 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.GetType(); ok { _spec.SetField(permission.FieldType, field.TypeString, value) } + if value, ok := _u.mutation.ParentCode(); ok { + _spec.SetField(permission.FieldParentCode, field.TypeString, value) + } if value, ok := _u.mutation.Path(); ok { _spec.SetField(permission.FieldPath, field.TypeString, value) } @@ -315,6 +337,20 @@ func (_u *PermissionUpdateOne) SetNillableType(v *string) *PermissionUpdateOne { return _u } +// SetParentCode sets the "parentCode" field. +func (_u *PermissionUpdateOne) SetParentCode(v string) *PermissionUpdateOne { + _u.mutation.SetParentCode(v) + return _u +} + +// SetNillableParentCode sets the "parentCode" field if the given value is not nil. +func (_u *PermissionUpdateOne) SetNillableParentCode(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetParentCode(*v) + } + return _u +} + // SetPath sets the "path" field. func (_u *PermissionUpdateOne) SetPath(v string) *PermissionUpdateOne { _u.mutation.SetPath(v) @@ -446,6 +482,11 @@ func (_u *PermissionUpdateOne) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Permission.type": %w`, err)} } } + if v, ok := _u.mutation.ParentCode(); ok { + if err := permission.ParentCodeValidator(v); err != nil { + return &ValidationError{Name: "parentCode", err: fmt.Errorf(`ent: validator failed for field "Permission.parentCode": %w`, err)} + } + } if v, ok := _u.mutation.Path(); ok { if err := permission.PathValidator(v); err != nil { return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Permission.path": %w`, err)} @@ -508,6 +549,9 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, if value, ok := _u.mutation.GetType(); ok { _spec.SetField(permission.FieldType, field.TypeString, value) } + if value, ok := _u.mutation.ParentCode(); ok { + _spec.SetField(permission.FieldParentCode, field.TypeString, value) + } if value, ok := _u.mutation.Path(); ok { _spec.SetField(permission.FieldPath, field.TypeString, value) } diff --git a/bj_power_mes/ent/predicate/predicate.go b/bj_power_mes/ent/predicate/predicate.go index 2524c59..23b956d 100644 --- a/bj_power_mes/ent/predicate/predicate.go +++ b/bj_power_mes/ent/predicate/predicate.go @@ -75,5 +75,8 @@ type WorkOrder func(*sql.Selector) // Workpiece is the predicate function for workpiece builders. type Workpiece func(*sql.Selector) +// WorkpieceBind is the predicate function for workpiecebind builders. +type WorkpieceBind func(*sql.Selector) + // WorkpieceProcess is the predicate function for workpieceprocess builders. type WorkpieceProcess func(*sql.Selector) diff --git a/bj_power_mes/ent/runtime.go b/bj_power_mes/ent/runtime.go index db6844a..c876a9a 100644 --- a/bj_power_mes/ent/runtime.go +++ b/bj_power_mes/ent/runtime.go @@ -26,6 +26,7 @@ import ( "bj_power_mes/ent/userstation" "bj_power_mes/ent/workorder" "bj_power_mes/ent/workpiece" + "bj_power_mes/ent/workpiecebind" "bj_power_mes/ent/workpieceprocess" "bj_power_mes/schema" "time" @@ -103,20 +104,24 @@ func init() { bomitem.DefaultManageMode = bomitemDescManageMode.Default.(string) // bomitem.ManageModeValidator is a validator for the "manageMode" field. It is called by the builders before save. bomitem.ManageModeValidator = bomitemDescManageMode.Validators[0].(func(string) error) + // bomitemDescProcessCode is the schema descriptor for processCode field. + bomitemDescProcessCode := bomitemFields[7].Descriptor() + // bomitem.DefaultProcessCode holds the default value on creation for the processCode field. + bomitem.DefaultProcessCode = bomitemDescProcessCode.Default.(int) // bomitemDescUnitQty is the schema descriptor for unitQty field. - bomitemDescUnitQty := bomitemFields[7].Descriptor() + bomitemDescUnitQty := bomitemFields[8].Descriptor() // bomitem.DefaultUnitQty holds the default value on creation for the unitQty field. bomitem.DefaultUnitQty = bomitemDescUnitQty.Default.(float64) // bomitemDescLossRate is the schema descriptor for lossRate field. - bomitemDescLossRate := bomitemFields[8].Descriptor() + bomitemDescLossRate := bomitemFields[9].Descriptor() // bomitem.DefaultLossRate holds the default value on creation for the lossRate field. bomitem.DefaultLossRate = bomitemDescLossRate.Default.(float64) // bomitemDescRequiredQty is the schema descriptor for requiredQty field. - bomitemDescRequiredQty := bomitemFields[9].Descriptor() + bomitemDescRequiredQty := bomitemFields[10].Descriptor() // bomitem.DefaultRequiredQty holds the default value on creation for the requiredQty field. bomitem.DefaultRequiredQty = bomitemDescRequiredQty.Default.(float64) // bomitemDescCreatedAt is the schema descriptor for createdAt field. - bomitemDescCreatedAt := bomitemFields[11].Descriptor() + bomitemDescCreatedAt := bomitemFields[12].Descriptor() // bomitem.DefaultCreatedAt holds the default value on creation for the createdAt field. bomitem.DefaultCreatedAt = bomitemDescCreatedAt.Default.(func() time.Time) // bomitemDescID is the schema descriptor for id field. @@ -359,30 +364,36 @@ func init() { permission.DefaultType = permissionDescType.Default.(string) // permission.TypeValidator is a validator for the "type" field. It is called by the builders before save. permission.TypeValidator = permissionDescType.Validators[0].(func(string) error) + // permissionDescParentCode is the schema descriptor for parentCode field. + permissionDescParentCode := permissionFields[4].Descriptor() + // permission.DefaultParentCode holds the default value on creation for the parentCode field. + permission.DefaultParentCode = permissionDescParentCode.Default.(string) + // permission.ParentCodeValidator is a validator for the "parentCode" field. It is called by the builders before save. + permission.ParentCodeValidator = permissionDescParentCode.Validators[0].(func(string) error) // permissionDescPath is the schema descriptor for path field. - permissionDescPath := permissionFields[4].Descriptor() + permissionDescPath := permissionFields[5].Descriptor() // permission.DefaultPath holds the default value on creation for the path field. permission.DefaultPath = permissionDescPath.Default.(string) // permission.PathValidator is a validator for the "path" field. It is called by the builders before save. permission.PathValidator = permissionDescPath.Validators[0].(func(string) error) // permissionDescIcon is the schema descriptor for icon field. - permissionDescIcon := permissionFields[5].Descriptor() + permissionDescIcon := permissionFields[6].Descriptor() // permission.DefaultIcon holds the default value on creation for the icon field. permission.DefaultIcon = permissionDescIcon.Default.(string) // permission.IconValidator is a validator for the "icon" field. It is called by the builders before save. permission.IconValidator = permissionDescIcon.Validators[0].(func(string) error) // permissionDescSort is the schema descriptor for sort field. - permissionDescSort := permissionFields[6].Descriptor() + permissionDescSort := permissionFields[7].Descriptor() // permission.DefaultSort holds the default value on creation for the sort field. permission.DefaultSort = permissionDescSort.Default.(int) // permissionDescRemark is the schema descriptor for remark field. - permissionDescRemark := permissionFields[7].Descriptor() + permissionDescRemark := permissionFields[8].Descriptor() // permission.DefaultRemark holds the default value on creation for the remark field. permission.DefaultRemark = permissionDescRemark.Default.(string) // permission.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. permission.RemarkValidator = permissionDescRemark.Validators[0].(func(string) error) // permissionDescCreatedAt is the schema descriptor for createdAt field. - permissionDescCreatedAt := permissionFields[8].Descriptor() + permissionDescCreatedAt := permissionFields[9].Descriptor() // permission.DefaultCreatedAt holds the default value on creation for the createdAt field. permission.DefaultCreatedAt = permissionDescCreatedAt.Default.(func() time.Time) // permissionDescID is the schema descriptor for id field. @@ -995,6 +1006,76 @@ func init() { workpieceDescID := workpieceFields[0].Descriptor() // workpiece.IDValidator is a validator for the "id" field. It is called by the builders before save. workpiece.IDValidator = workpieceDescID.Validators[0].(func(int) error) + workpiecebindFields := schema.WorkpieceBind{}.Fields() + _ = workpiecebindFields + // workpiecebindDescSn is the schema descriptor for sn field. + workpiecebindDescSn := workpiecebindFields[1].Descriptor() + // workpiecebind.SnValidator is a validator for the "sn" field. It is called by the builders before save. + workpiecebind.SnValidator = workpiecebindDescSn.Validators[0].(func(string) error) + // workpiecebindDescOrderNo is the schema descriptor for orderNo field. + workpiecebindDescOrderNo := workpiecebindFields[2].Descriptor() + // workpiecebind.DefaultOrderNo holds the default value on creation for the orderNo field. + workpiecebind.DefaultOrderNo = workpiecebindDescOrderNo.Default.(string) + // workpiecebind.OrderNoValidator is a validator for the "orderNo" field. It is called by the builders before save. + workpiecebind.OrderNoValidator = workpiecebindDescOrderNo.Validators[0].(func(string) error) + // workpiecebindDescStationNo is the schema descriptor for stationNo field. + workpiecebindDescStationNo := workpiecebindFields[4].Descriptor() + // workpiecebind.DefaultStationNo holds the default value on creation for the stationNo field. + workpiecebind.DefaultStationNo = workpiecebindDescStationNo.Default.(string) + // workpiecebind.StationNoValidator is a validator for the "stationNo" field. It is called by the builders before save. + workpiecebind.StationNoValidator = workpiecebindDescStationNo.Validators[0].(func(string) error) + // workpiecebindDescMaterialCode is the schema descriptor for materialCode field. + workpiecebindDescMaterialCode := workpiecebindFields[5].Descriptor() + // workpiecebind.MaterialCodeValidator is a validator for the "materialCode" field. It is called by the builders before save. + workpiecebind.MaterialCodeValidator = workpiecebindDescMaterialCode.Validators[0].(func(string) error) + // workpiecebindDescMaterialName is the schema descriptor for materialName field. + workpiecebindDescMaterialName := workpiecebindFields[6].Descriptor() + // workpiecebind.DefaultMaterialName holds the default value on creation for the materialName field. + workpiecebind.DefaultMaterialName = workpiecebindDescMaterialName.Default.(string) + // workpiecebind.MaterialNameValidator is a validator for the "materialName" field. It is called by the builders before save. + workpiecebind.MaterialNameValidator = workpiecebindDescMaterialName.Validators[0].(func(string) error) + // workpiecebindDescSpec is the schema descriptor for spec field. + workpiecebindDescSpec := workpiecebindFields[7].Descriptor() + // workpiecebind.DefaultSpec holds the default value on creation for the spec field. + workpiecebind.DefaultSpec = workpiecebindDescSpec.Default.(string) + // workpiecebind.SpecValidator is a validator for the "spec" field. It is called by the builders before save. + workpiecebind.SpecValidator = workpiecebindDescSpec.Validators[0].(func(string) error) + // workpiecebindDescUnit is the schema descriptor for unit field. + workpiecebindDescUnit := workpiecebindFields[8].Descriptor() + // workpiecebind.DefaultUnit holds the default value on creation for the unit field. + workpiecebind.DefaultUnit = workpiecebindDescUnit.Default.(string) + // workpiecebind.UnitValidator is a validator for the "unit" field. It is called by the builders before save. + workpiecebind.UnitValidator = workpiecebindDescUnit.Validators[0].(func(string) error) + // workpiecebindDescManageMode is the schema descriptor for manageMode field. + workpiecebindDescManageMode := workpiecebindFields[9].Descriptor() + // workpiecebind.DefaultManageMode holds the default value on creation for the manageMode field. + workpiecebind.DefaultManageMode = workpiecebindDescManageMode.Default.(string) + // workpiecebind.ManageModeValidator is a validator for the "manageMode" field. It is called by the builders before save. + workpiecebind.ManageModeValidator = workpiecebindDescManageMode.Validators[0].(func(string) error) + // workpiecebindDescBindValue is the schema descriptor for bindValue field. + workpiecebindDescBindValue := workpiecebindFields[10].Descriptor() + // workpiecebind.BindValueValidator is a validator for the "bindValue" field. It is called by the builders before save. + workpiecebind.BindValueValidator = workpiecebindDescBindValue.Validators[0].(func(string) error) + // workpiecebindDescBindType is the schema descriptor for bindType field. + workpiecebindDescBindType := workpiecebindFields[11].Descriptor() + // workpiecebind.DefaultBindType holds the default value on creation for the bindType field. + workpiecebind.DefaultBindType = workpiecebindDescBindType.Default.(string) + // workpiecebind.BindTypeValidator is a validator for the "bindType" field. It is called by the builders before save. + workpiecebind.BindTypeValidator = workpiecebindDescBindType.Validators[0].(func(string) error) + // workpiecebindDescOperator is the schema descriptor for operator field. + workpiecebindDescOperator := workpiecebindFields[12].Descriptor() + // workpiecebind.DefaultOperator holds the default value on creation for the operator field. + workpiecebind.DefaultOperator = workpiecebindDescOperator.Default.(string) + // workpiecebind.OperatorValidator is a validator for the "operator" field. It is called by the builders before save. + workpiecebind.OperatorValidator = workpiecebindDescOperator.Validators[0].(func(string) error) + // workpiecebindDescCreatedAt is the schema descriptor for createdAt field. + workpiecebindDescCreatedAt := workpiecebindFields[13].Descriptor() + // workpiecebind.DefaultCreatedAt holds the default value on creation for the createdAt field. + workpiecebind.DefaultCreatedAt = workpiecebindDescCreatedAt.Default.(func() time.Time) + // workpiecebindDescID is the schema descriptor for id field. + workpiecebindDescID := workpiecebindFields[0].Descriptor() + // workpiecebind.IDValidator is a validator for the "id" field. It is called by the builders before save. + workpiecebind.IDValidator = workpiecebindDescID.Validators[0].(func(int) error) workpieceprocessFields := schema.WorkpieceProcess{}.Fields() _ = workpieceprocessFields // workpieceprocessDescSn is the schema descriptor for sn field. diff --git a/bj_power_mes/ent/tx.go b/bj_power_mes/ent/tx.go index 9febec6..31b202e 100644 --- a/bj_power_mes/ent/tx.go +++ b/bj_power_mes/ent/tx.go @@ -60,6 +60,8 @@ type Tx struct { WorkOrder *WorkOrderClient // Workpiece is the client for interacting with the Workpiece builders. Workpiece *WorkpieceClient + // WorkpieceBind is the client for interacting with the WorkpieceBind builders. + WorkpieceBind *WorkpieceBindClient // WorkpieceProcess is the client for interacting with the WorkpieceProcess builders. WorkpieceProcess *WorkpieceProcessClient @@ -216,6 +218,7 @@ func (tx *Tx) init() { tx.UserStation = NewUserStationClient(tx.config) tx.WorkOrder = NewWorkOrderClient(tx.config) tx.Workpiece = NewWorkpieceClient(tx.config) + tx.WorkpieceBind = NewWorkpieceBindClient(tx.config) tx.WorkpieceProcess = NewWorkpieceProcessClient(tx.config) } diff --git a/bj_power_mes/ent/workpiecebind.go b/bj_power_mes/ent/workpiecebind.go new file mode 100644 index 0000000..61fd8f9 --- /dev/null +++ b/bj_power_mes/ent/workpiecebind.go @@ -0,0 +1,238 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/workpiecebind" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// WorkpieceBind is the model entity for the WorkpieceBind schema. +type WorkpieceBind struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // 工件SN + Sn string `json:"sn,omitempty"` + // 工单号 + OrderNo string `json:"orderNo,omitempty"` + // 装配工序 1~12 + ProcessCode int `json:"processCode,omitempty"` + // 绑定工位 + StationNo string `json:"stationNo,omitempty"` + // 物料编码 + MaterialCode string `json:"materialCode,omitempty"` + // 物料名称 + MaterialName string `json:"materialName,omitempty"` + // 规格 + Spec string `json:"spec,omitempty"` + // 单位 + Unit string `json:"unit,omitempty"` + // ManageMode holds the value of the "manageMode" field. + ManageMode string `json:"manageMode,omitempty"` + // 绑定值:批次号 或 SN + BindValue string `json:"bindValue,omitempty"` + // BindType holds the value of the "bindType" field. + BindType string `json:"bindType,omitempty"` + // 操作人 + Operator string `json:"operator,omitempty"` + // 绑定时间 + CreatedAt time.Time `json:"createdAt,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*WorkpieceBind) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case workpiecebind.FieldID, workpiecebind.FieldProcessCode: + values[i] = new(sql.NullInt64) + case workpiecebind.FieldSn, workpiecebind.FieldOrderNo, workpiecebind.FieldStationNo, workpiecebind.FieldMaterialCode, workpiecebind.FieldMaterialName, workpiecebind.FieldSpec, workpiecebind.FieldUnit, workpiecebind.FieldManageMode, workpiecebind.FieldBindValue, workpiecebind.FieldBindType, workpiecebind.FieldOperator: + values[i] = new(sql.NullString) + case workpiecebind.FieldCreatedAt: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the WorkpieceBind fields. +func (_m *WorkpieceBind) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case workpiecebind.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int(value.Int64) + case workpiecebind.FieldSn: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field sn", values[i]) + } else if value.Valid { + _m.Sn = value.String + } + case workpiecebind.FieldOrderNo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field orderNo", values[i]) + } else if value.Valid { + _m.OrderNo = value.String + } + case workpiecebind.FieldProcessCode: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field processCode", values[i]) + } else if value.Valid { + _m.ProcessCode = int(value.Int64) + } + case workpiecebind.FieldStationNo: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field stationNo", values[i]) + } else if value.Valid { + _m.StationNo = value.String + } + case workpiecebind.FieldMaterialCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field materialCode", values[i]) + } else if value.Valid { + _m.MaterialCode = value.String + } + case workpiecebind.FieldMaterialName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field materialName", values[i]) + } else if value.Valid { + _m.MaterialName = value.String + } + case workpiecebind.FieldSpec: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field spec", values[i]) + } else if value.Valid { + _m.Spec = value.String + } + case workpiecebind.FieldUnit: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field unit", values[i]) + } else if value.Valid { + _m.Unit = value.String + } + case workpiecebind.FieldManageMode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field manageMode", values[i]) + } else if value.Valid { + _m.ManageMode = value.String + } + case workpiecebind.FieldBindValue: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field bindValue", values[i]) + } else if value.Valid { + _m.BindValue = value.String + } + case workpiecebind.FieldBindType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field bindType", values[i]) + } else if value.Valid { + _m.BindType = value.String + } + case workpiecebind.FieldOperator: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field operator", values[i]) + } else if value.Valid { + _m.Operator = value.String + } + case workpiecebind.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field createdAt", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the WorkpieceBind. +// This includes values selected through modifiers, order, etc. +func (_m *WorkpieceBind) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this WorkpieceBind. +// Note that you need to call WorkpieceBind.Unwrap() before calling this method if this WorkpieceBind +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *WorkpieceBind) Update() *WorkpieceBindUpdateOne { + return NewWorkpieceBindClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the WorkpieceBind entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *WorkpieceBind) Unwrap() *WorkpieceBind { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: WorkpieceBind is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *WorkpieceBind) String() string { + var builder strings.Builder + builder.WriteString("WorkpieceBind(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("sn=") + builder.WriteString(_m.Sn) + builder.WriteString(", ") + builder.WriteString("orderNo=") + builder.WriteString(_m.OrderNo) + builder.WriteString(", ") + builder.WriteString("processCode=") + builder.WriteString(fmt.Sprintf("%v", _m.ProcessCode)) + builder.WriteString(", ") + builder.WriteString("stationNo=") + builder.WriteString(_m.StationNo) + builder.WriteString(", ") + builder.WriteString("materialCode=") + builder.WriteString(_m.MaterialCode) + builder.WriteString(", ") + builder.WriteString("materialName=") + builder.WriteString(_m.MaterialName) + builder.WriteString(", ") + builder.WriteString("spec=") + builder.WriteString(_m.Spec) + builder.WriteString(", ") + builder.WriteString("unit=") + builder.WriteString(_m.Unit) + builder.WriteString(", ") + builder.WriteString("manageMode=") + builder.WriteString(_m.ManageMode) + builder.WriteString(", ") + builder.WriteString("bindValue=") + builder.WriteString(_m.BindValue) + builder.WriteString(", ") + builder.WriteString("bindType=") + builder.WriteString(_m.BindType) + builder.WriteString(", ") + builder.WriteString("operator=") + builder.WriteString(_m.Operator) + builder.WriteString(", ") + builder.WriteString("createdAt=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// WorkpieceBinds is a parsable slice of WorkpieceBind. +type WorkpieceBinds []*WorkpieceBind diff --git a/bj_power_mes/ent/workpiecebind/where.go b/bj_power_mes/ent/workpiecebind/where.go new file mode 100644 index 0000000..c8c7da2 --- /dev/null +++ b/bj_power_mes/ent/workpiecebind/where.go @@ -0,0 +1,930 @@ +// Code generated by ent, DO NOT EDIT. + +package workpiecebind + +import ( + "bj_power_mes/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldID, id)) +} + +// Sn applies equality check predicate on the "sn" field. It's identical to SnEQ. +func Sn(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldSn, v)) +} + +// OrderNo applies equality check predicate on the "orderNo" field. It's identical to OrderNoEQ. +func OrderNo(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldOrderNo, v)) +} + +// ProcessCode applies equality check predicate on the "processCode" field. It's identical to ProcessCodeEQ. +func ProcessCode(v int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldProcessCode, v)) +} + +// StationNo applies equality check predicate on the "stationNo" field. It's identical to StationNoEQ. +func StationNo(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldStationNo, v)) +} + +// MaterialCode applies equality check predicate on the "materialCode" field. It's identical to MaterialCodeEQ. +func MaterialCode(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldMaterialCode, v)) +} + +// MaterialName applies equality check predicate on the "materialName" field. It's identical to MaterialNameEQ. +func MaterialName(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldMaterialName, v)) +} + +// Spec applies equality check predicate on the "spec" field. It's identical to SpecEQ. +func Spec(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldSpec, v)) +} + +// Unit applies equality check predicate on the "unit" field. It's identical to UnitEQ. +func Unit(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldUnit, v)) +} + +// ManageMode applies equality check predicate on the "manageMode" field. It's identical to ManageModeEQ. +func ManageMode(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldManageMode, v)) +} + +// BindValue applies equality check predicate on the "bindValue" field. It's identical to BindValueEQ. +func BindValue(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldBindValue, v)) +} + +// BindType applies equality check predicate on the "bindType" field. It's identical to BindTypeEQ. +func BindType(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldBindType, v)) +} + +// Operator applies equality check predicate on the "operator" field. It's identical to OperatorEQ. +func Operator(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldOperator, v)) +} + +// CreatedAt applies equality check predicate on the "createdAt" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldCreatedAt, v)) +} + +// SnEQ applies the EQ predicate on the "sn" field. +func SnEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldSn, v)) +} + +// SnNEQ applies the NEQ predicate on the "sn" field. +func SnNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldSn, v)) +} + +// SnIn applies the In predicate on the "sn" field. +func SnIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldSn, vs...)) +} + +// SnNotIn applies the NotIn predicate on the "sn" field. +func SnNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldSn, vs...)) +} + +// SnGT applies the GT predicate on the "sn" field. +func SnGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldSn, v)) +} + +// SnGTE applies the GTE predicate on the "sn" field. +func SnGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldSn, v)) +} + +// SnLT applies the LT predicate on the "sn" field. +func SnLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldSn, v)) +} + +// SnLTE applies the LTE predicate on the "sn" field. +func SnLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldSn, v)) +} + +// SnContains applies the Contains predicate on the "sn" field. +func SnContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldSn, v)) +} + +// SnHasPrefix applies the HasPrefix predicate on the "sn" field. +func SnHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldSn, v)) +} + +// SnHasSuffix applies the HasSuffix predicate on the "sn" field. +func SnHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldSn, v)) +} + +// SnEqualFold applies the EqualFold predicate on the "sn" field. +func SnEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldSn, v)) +} + +// SnContainsFold applies the ContainsFold predicate on the "sn" field. +func SnContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldSn, v)) +} + +// OrderNoEQ applies the EQ predicate on the "orderNo" field. +func OrderNoEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldOrderNo, v)) +} + +// OrderNoNEQ applies the NEQ predicate on the "orderNo" field. +func OrderNoNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldOrderNo, v)) +} + +// OrderNoIn applies the In predicate on the "orderNo" field. +func OrderNoIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldOrderNo, vs...)) +} + +// OrderNoNotIn applies the NotIn predicate on the "orderNo" field. +func OrderNoNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldOrderNo, vs...)) +} + +// OrderNoGT applies the GT predicate on the "orderNo" field. +func OrderNoGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldOrderNo, v)) +} + +// OrderNoGTE applies the GTE predicate on the "orderNo" field. +func OrderNoGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldOrderNo, v)) +} + +// OrderNoLT applies the LT predicate on the "orderNo" field. +func OrderNoLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldOrderNo, v)) +} + +// OrderNoLTE applies the LTE predicate on the "orderNo" field. +func OrderNoLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldOrderNo, v)) +} + +// OrderNoContains applies the Contains predicate on the "orderNo" field. +func OrderNoContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldOrderNo, v)) +} + +// OrderNoHasPrefix applies the HasPrefix predicate on the "orderNo" field. +func OrderNoHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldOrderNo, v)) +} + +// OrderNoHasSuffix applies the HasSuffix predicate on the "orderNo" field. +func OrderNoHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldOrderNo, v)) +} + +// OrderNoEqualFold applies the EqualFold predicate on the "orderNo" field. +func OrderNoEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldOrderNo, v)) +} + +// OrderNoContainsFold applies the ContainsFold predicate on the "orderNo" field. +func OrderNoContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldOrderNo, v)) +} + +// ProcessCodeEQ applies the EQ predicate on the "processCode" field. +func ProcessCodeEQ(v int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldProcessCode, v)) +} + +// ProcessCodeNEQ applies the NEQ predicate on the "processCode" field. +func ProcessCodeNEQ(v int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldProcessCode, v)) +} + +// ProcessCodeIn applies the In predicate on the "processCode" field. +func ProcessCodeIn(vs ...int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldProcessCode, vs...)) +} + +// ProcessCodeNotIn applies the NotIn predicate on the "processCode" field. +func ProcessCodeNotIn(vs ...int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldProcessCode, vs...)) +} + +// ProcessCodeGT applies the GT predicate on the "processCode" field. +func ProcessCodeGT(v int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldProcessCode, v)) +} + +// ProcessCodeGTE applies the GTE predicate on the "processCode" field. +func ProcessCodeGTE(v int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldProcessCode, v)) +} + +// ProcessCodeLT applies the LT predicate on the "processCode" field. +func ProcessCodeLT(v int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldProcessCode, v)) +} + +// ProcessCodeLTE applies the LTE predicate on the "processCode" field. +func ProcessCodeLTE(v int) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldProcessCode, v)) +} + +// StationNoEQ applies the EQ predicate on the "stationNo" field. +func StationNoEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldStationNo, v)) +} + +// StationNoNEQ applies the NEQ predicate on the "stationNo" field. +func StationNoNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldStationNo, v)) +} + +// StationNoIn applies the In predicate on the "stationNo" field. +func StationNoIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldStationNo, vs...)) +} + +// StationNoNotIn applies the NotIn predicate on the "stationNo" field. +func StationNoNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldStationNo, vs...)) +} + +// StationNoGT applies the GT predicate on the "stationNo" field. +func StationNoGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldStationNo, v)) +} + +// StationNoGTE applies the GTE predicate on the "stationNo" field. +func StationNoGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldStationNo, v)) +} + +// StationNoLT applies the LT predicate on the "stationNo" field. +func StationNoLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldStationNo, v)) +} + +// StationNoLTE applies the LTE predicate on the "stationNo" field. +func StationNoLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldStationNo, v)) +} + +// StationNoContains applies the Contains predicate on the "stationNo" field. +func StationNoContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldStationNo, v)) +} + +// StationNoHasPrefix applies the HasPrefix predicate on the "stationNo" field. +func StationNoHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldStationNo, v)) +} + +// StationNoHasSuffix applies the HasSuffix predicate on the "stationNo" field. +func StationNoHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldStationNo, v)) +} + +// StationNoEqualFold applies the EqualFold predicate on the "stationNo" field. +func StationNoEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldStationNo, v)) +} + +// StationNoContainsFold applies the ContainsFold predicate on the "stationNo" field. +func StationNoContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldStationNo, v)) +} + +// MaterialCodeEQ applies the EQ predicate on the "materialCode" field. +func MaterialCodeEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldMaterialCode, v)) +} + +// MaterialCodeNEQ applies the NEQ predicate on the "materialCode" field. +func MaterialCodeNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldMaterialCode, v)) +} + +// MaterialCodeIn applies the In predicate on the "materialCode" field. +func MaterialCodeIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldMaterialCode, vs...)) +} + +// MaterialCodeNotIn applies the NotIn predicate on the "materialCode" field. +func MaterialCodeNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldMaterialCode, vs...)) +} + +// MaterialCodeGT applies the GT predicate on the "materialCode" field. +func MaterialCodeGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldMaterialCode, v)) +} + +// MaterialCodeGTE applies the GTE predicate on the "materialCode" field. +func MaterialCodeGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldMaterialCode, v)) +} + +// MaterialCodeLT applies the LT predicate on the "materialCode" field. +func MaterialCodeLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldMaterialCode, v)) +} + +// MaterialCodeLTE applies the LTE predicate on the "materialCode" field. +func MaterialCodeLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldMaterialCode, v)) +} + +// MaterialCodeContains applies the Contains predicate on the "materialCode" field. +func MaterialCodeContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldMaterialCode, v)) +} + +// MaterialCodeHasPrefix applies the HasPrefix predicate on the "materialCode" field. +func MaterialCodeHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldMaterialCode, v)) +} + +// MaterialCodeHasSuffix applies the HasSuffix predicate on the "materialCode" field. +func MaterialCodeHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldMaterialCode, v)) +} + +// MaterialCodeEqualFold applies the EqualFold predicate on the "materialCode" field. +func MaterialCodeEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldMaterialCode, v)) +} + +// MaterialCodeContainsFold applies the ContainsFold predicate on the "materialCode" field. +func MaterialCodeContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldMaterialCode, v)) +} + +// MaterialNameEQ applies the EQ predicate on the "materialName" field. +func MaterialNameEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldMaterialName, v)) +} + +// MaterialNameNEQ applies the NEQ predicate on the "materialName" field. +func MaterialNameNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldMaterialName, v)) +} + +// MaterialNameIn applies the In predicate on the "materialName" field. +func MaterialNameIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldMaterialName, vs...)) +} + +// MaterialNameNotIn applies the NotIn predicate on the "materialName" field. +func MaterialNameNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldMaterialName, vs...)) +} + +// MaterialNameGT applies the GT predicate on the "materialName" field. +func MaterialNameGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldMaterialName, v)) +} + +// MaterialNameGTE applies the GTE predicate on the "materialName" field. +func MaterialNameGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldMaterialName, v)) +} + +// MaterialNameLT applies the LT predicate on the "materialName" field. +func MaterialNameLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldMaterialName, v)) +} + +// MaterialNameLTE applies the LTE predicate on the "materialName" field. +func MaterialNameLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldMaterialName, v)) +} + +// MaterialNameContains applies the Contains predicate on the "materialName" field. +func MaterialNameContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldMaterialName, v)) +} + +// MaterialNameHasPrefix applies the HasPrefix predicate on the "materialName" field. +func MaterialNameHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldMaterialName, v)) +} + +// MaterialNameHasSuffix applies the HasSuffix predicate on the "materialName" field. +func MaterialNameHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldMaterialName, v)) +} + +// MaterialNameEqualFold applies the EqualFold predicate on the "materialName" field. +func MaterialNameEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldMaterialName, v)) +} + +// MaterialNameContainsFold applies the ContainsFold predicate on the "materialName" field. +func MaterialNameContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldMaterialName, v)) +} + +// SpecEQ applies the EQ predicate on the "spec" field. +func SpecEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldSpec, v)) +} + +// SpecNEQ applies the NEQ predicate on the "spec" field. +func SpecNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldSpec, v)) +} + +// SpecIn applies the In predicate on the "spec" field. +func SpecIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldSpec, vs...)) +} + +// SpecNotIn applies the NotIn predicate on the "spec" field. +func SpecNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldSpec, vs...)) +} + +// SpecGT applies the GT predicate on the "spec" field. +func SpecGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldSpec, v)) +} + +// SpecGTE applies the GTE predicate on the "spec" field. +func SpecGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldSpec, v)) +} + +// SpecLT applies the LT predicate on the "spec" field. +func SpecLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldSpec, v)) +} + +// SpecLTE applies the LTE predicate on the "spec" field. +func SpecLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldSpec, v)) +} + +// SpecContains applies the Contains predicate on the "spec" field. +func SpecContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldSpec, v)) +} + +// SpecHasPrefix applies the HasPrefix predicate on the "spec" field. +func SpecHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldSpec, v)) +} + +// SpecHasSuffix applies the HasSuffix predicate on the "spec" field. +func SpecHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldSpec, v)) +} + +// SpecEqualFold applies the EqualFold predicate on the "spec" field. +func SpecEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldSpec, v)) +} + +// SpecContainsFold applies the ContainsFold predicate on the "spec" field. +func SpecContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldSpec, v)) +} + +// UnitEQ applies the EQ predicate on the "unit" field. +func UnitEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldUnit, v)) +} + +// UnitNEQ applies the NEQ predicate on the "unit" field. +func UnitNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldUnit, v)) +} + +// UnitIn applies the In predicate on the "unit" field. +func UnitIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldUnit, vs...)) +} + +// UnitNotIn applies the NotIn predicate on the "unit" field. +func UnitNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldUnit, vs...)) +} + +// UnitGT applies the GT predicate on the "unit" field. +func UnitGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldUnit, v)) +} + +// UnitGTE applies the GTE predicate on the "unit" field. +func UnitGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldUnit, v)) +} + +// UnitLT applies the LT predicate on the "unit" field. +func UnitLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldUnit, v)) +} + +// UnitLTE applies the LTE predicate on the "unit" field. +func UnitLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldUnit, v)) +} + +// UnitContains applies the Contains predicate on the "unit" field. +func UnitContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldUnit, v)) +} + +// UnitHasPrefix applies the HasPrefix predicate on the "unit" field. +func UnitHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldUnit, v)) +} + +// UnitHasSuffix applies the HasSuffix predicate on the "unit" field. +func UnitHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldUnit, v)) +} + +// UnitEqualFold applies the EqualFold predicate on the "unit" field. +func UnitEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldUnit, v)) +} + +// UnitContainsFold applies the ContainsFold predicate on the "unit" field. +func UnitContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldUnit, v)) +} + +// ManageModeEQ applies the EQ predicate on the "manageMode" field. +func ManageModeEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldManageMode, v)) +} + +// ManageModeNEQ applies the NEQ predicate on the "manageMode" field. +func ManageModeNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldManageMode, v)) +} + +// ManageModeIn applies the In predicate on the "manageMode" field. +func ManageModeIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldManageMode, vs...)) +} + +// ManageModeNotIn applies the NotIn predicate on the "manageMode" field. +func ManageModeNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldManageMode, vs...)) +} + +// ManageModeGT applies the GT predicate on the "manageMode" field. +func ManageModeGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldManageMode, v)) +} + +// ManageModeGTE applies the GTE predicate on the "manageMode" field. +func ManageModeGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldManageMode, v)) +} + +// ManageModeLT applies the LT predicate on the "manageMode" field. +func ManageModeLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldManageMode, v)) +} + +// ManageModeLTE applies the LTE predicate on the "manageMode" field. +func ManageModeLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldManageMode, v)) +} + +// ManageModeContains applies the Contains predicate on the "manageMode" field. +func ManageModeContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldManageMode, v)) +} + +// ManageModeHasPrefix applies the HasPrefix predicate on the "manageMode" field. +func ManageModeHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldManageMode, v)) +} + +// ManageModeHasSuffix applies the HasSuffix predicate on the "manageMode" field. +func ManageModeHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldManageMode, v)) +} + +// ManageModeEqualFold applies the EqualFold predicate on the "manageMode" field. +func ManageModeEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldManageMode, v)) +} + +// ManageModeContainsFold applies the ContainsFold predicate on the "manageMode" field. +func ManageModeContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldManageMode, v)) +} + +// BindValueEQ applies the EQ predicate on the "bindValue" field. +func BindValueEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldBindValue, v)) +} + +// BindValueNEQ applies the NEQ predicate on the "bindValue" field. +func BindValueNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldBindValue, v)) +} + +// BindValueIn applies the In predicate on the "bindValue" field. +func BindValueIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldBindValue, vs...)) +} + +// BindValueNotIn applies the NotIn predicate on the "bindValue" field. +func BindValueNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldBindValue, vs...)) +} + +// BindValueGT applies the GT predicate on the "bindValue" field. +func BindValueGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldBindValue, v)) +} + +// BindValueGTE applies the GTE predicate on the "bindValue" field. +func BindValueGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldBindValue, v)) +} + +// BindValueLT applies the LT predicate on the "bindValue" field. +func BindValueLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldBindValue, v)) +} + +// BindValueLTE applies the LTE predicate on the "bindValue" field. +func BindValueLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldBindValue, v)) +} + +// BindValueContains applies the Contains predicate on the "bindValue" field. +func BindValueContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldBindValue, v)) +} + +// BindValueHasPrefix applies the HasPrefix predicate on the "bindValue" field. +func BindValueHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldBindValue, v)) +} + +// BindValueHasSuffix applies the HasSuffix predicate on the "bindValue" field. +func BindValueHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldBindValue, v)) +} + +// BindValueEqualFold applies the EqualFold predicate on the "bindValue" field. +func BindValueEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldBindValue, v)) +} + +// BindValueContainsFold applies the ContainsFold predicate on the "bindValue" field. +func BindValueContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldBindValue, v)) +} + +// BindTypeEQ applies the EQ predicate on the "bindType" field. +func BindTypeEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldBindType, v)) +} + +// BindTypeNEQ applies the NEQ predicate on the "bindType" field. +func BindTypeNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldBindType, v)) +} + +// BindTypeIn applies the In predicate on the "bindType" field. +func BindTypeIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldBindType, vs...)) +} + +// BindTypeNotIn applies the NotIn predicate on the "bindType" field. +func BindTypeNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldBindType, vs...)) +} + +// BindTypeGT applies the GT predicate on the "bindType" field. +func BindTypeGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldBindType, v)) +} + +// BindTypeGTE applies the GTE predicate on the "bindType" field. +func BindTypeGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldBindType, v)) +} + +// BindTypeLT applies the LT predicate on the "bindType" field. +func BindTypeLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldBindType, v)) +} + +// BindTypeLTE applies the LTE predicate on the "bindType" field. +func BindTypeLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldBindType, v)) +} + +// BindTypeContains applies the Contains predicate on the "bindType" field. +func BindTypeContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldBindType, v)) +} + +// BindTypeHasPrefix applies the HasPrefix predicate on the "bindType" field. +func BindTypeHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldBindType, v)) +} + +// BindTypeHasSuffix applies the HasSuffix predicate on the "bindType" field. +func BindTypeHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldBindType, v)) +} + +// BindTypeEqualFold applies the EqualFold predicate on the "bindType" field. +func BindTypeEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldBindType, v)) +} + +// BindTypeContainsFold applies the ContainsFold predicate on the "bindType" field. +func BindTypeContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldBindType, v)) +} + +// OperatorEQ applies the EQ predicate on the "operator" field. +func OperatorEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldOperator, v)) +} + +// OperatorNEQ applies the NEQ predicate on the "operator" field. +func OperatorNEQ(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldOperator, v)) +} + +// OperatorIn applies the In predicate on the "operator" field. +func OperatorIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldOperator, vs...)) +} + +// OperatorNotIn applies the NotIn predicate on the "operator" field. +func OperatorNotIn(vs ...string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldOperator, vs...)) +} + +// OperatorGT applies the GT predicate on the "operator" field. +func OperatorGT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldOperator, v)) +} + +// OperatorGTE applies the GTE predicate on the "operator" field. +func OperatorGTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldOperator, v)) +} + +// OperatorLT applies the LT predicate on the "operator" field. +func OperatorLT(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldOperator, v)) +} + +// OperatorLTE applies the LTE predicate on the "operator" field. +func OperatorLTE(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldOperator, v)) +} + +// OperatorContains applies the Contains predicate on the "operator" field. +func OperatorContains(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContains(FieldOperator, v)) +} + +// OperatorHasPrefix applies the HasPrefix predicate on the "operator" field. +func OperatorHasPrefix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasPrefix(FieldOperator, v)) +} + +// OperatorHasSuffix applies the HasSuffix predicate on the "operator" field. +func OperatorHasSuffix(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldHasSuffix(FieldOperator, v)) +} + +// OperatorEqualFold applies the EqualFold predicate on the "operator" field. +func OperatorEqualFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEqualFold(FieldOperator, v)) +} + +// OperatorContainsFold applies the ContainsFold predicate on the "operator" field. +func OperatorContainsFold(v string) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldContainsFold(FieldOperator, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "createdAt" field. +func CreatedAtEQ(v time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "createdAt" field. +func CreatedAtNEQ(v time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "createdAt" field. +func CreatedAtIn(vs ...time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "createdAt" field. +func CreatedAtNotIn(vs ...time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "createdAt" field. +func CreatedAtGT(v time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "createdAt" field. +func CreatedAtGTE(v time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "createdAt" field. +func CreatedAtLT(v time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "createdAt" field. +func CreatedAtLTE(v time.Time) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.FieldLTE(FieldCreatedAt, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.WorkpieceBind) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.WorkpieceBind) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.WorkpieceBind) predicate.WorkpieceBind { + return predicate.WorkpieceBind(sql.NotPredicates(p)) +} diff --git a/bj_power_mes/ent/workpiecebind/workpiecebind.go b/bj_power_mes/ent/workpiecebind/workpiecebind.go new file mode 100644 index 0000000..2808a88 --- /dev/null +++ b/bj_power_mes/ent/workpiecebind/workpiecebind.go @@ -0,0 +1,190 @@ +// Code generated by ent, DO NOT EDIT. + +package workpiecebind + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the workpiecebind type in the database. + Label = "workpiece_bind" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldSn holds the string denoting the sn field in the database. + FieldSn = "sn" + // FieldOrderNo holds the string denoting the orderno field in the database. + FieldOrderNo = "order_no" + // FieldProcessCode holds the string denoting the processcode field in the database. + FieldProcessCode = "process_code" + // FieldStationNo holds the string denoting the stationno field in the database. + FieldStationNo = "station_no" + // FieldMaterialCode holds the string denoting the materialcode field in the database. + FieldMaterialCode = "material_code" + // FieldMaterialName holds the string denoting the materialname field in the database. + FieldMaterialName = "material_name" + // FieldSpec holds the string denoting the spec field in the database. + FieldSpec = "spec" + // FieldUnit holds the string denoting the unit field in the database. + FieldUnit = "unit" + // FieldManageMode holds the string denoting the managemode field in the database. + FieldManageMode = "manage_mode" + // FieldBindValue holds the string denoting the bindvalue field in the database. + FieldBindValue = "bind_value" + // FieldBindType holds the string denoting the bindtype field in the database. + FieldBindType = "bind_type" + // FieldOperator holds the string denoting the operator field in the database. + FieldOperator = "operator" + // FieldCreatedAt holds the string denoting the createdat field in the database. + FieldCreatedAt = "created_at" + // Table holds the table name of the workpiecebind in the database. + Table = "workpiece_bind" +) + +// Columns holds all SQL columns for workpiecebind fields. +var Columns = []string{ + FieldID, + FieldSn, + FieldOrderNo, + FieldProcessCode, + FieldStationNo, + FieldMaterialCode, + FieldMaterialName, + FieldSpec, + FieldUnit, + FieldManageMode, + FieldBindValue, + FieldBindType, + FieldOperator, + FieldCreatedAt, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // SnValidator is a validator for the "sn" field. It is called by the builders before save. + SnValidator func(string) error + // DefaultOrderNo holds the default value on creation for the "orderNo" field. + DefaultOrderNo string + // OrderNoValidator is a validator for the "orderNo" field. It is called by the builders before save. + OrderNoValidator func(string) error + // DefaultStationNo holds the default value on creation for the "stationNo" field. + DefaultStationNo string + // StationNoValidator is a validator for the "stationNo" field. It is called by the builders before save. + StationNoValidator func(string) error + // MaterialCodeValidator is a validator for the "materialCode" field. It is called by the builders before save. + MaterialCodeValidator func(string) error + // DefaultMaterialName holds the default value on creation for the "materialName" field. + DefaultMaterialName string + // MaterialNameValidator is a validator for the "materialName" field. It is called by the builders before save. + MaterialNameValidator func(string) error + // DefaultSpec holds the default value on creation for the "spec" field. + DefaultSpec string + // SpecValidator is a validator for the "spec" field. It is called by the builders before save. + SpecValidator func(string) error + // DefaultUnit holds the default value on creation for the "unit" field. + DefaultUnit string + // UnitValidator is a validator for the "unit" field. It is called by the builders before save. + UnitValidator func(string) error + // DefaultManageMode holds the default value on creation for the "manageMode" field. + DefaultManageMode string + // ManageModeValidator is a validator for the "manageMode" field. It is called by the builders before save. + ManageModeValidator func(string) error + // BindValueValidator is a validator for the "bindValue" field. It is called by the builders before save. + BindValueValidator func(string) error + // DefaultBindType holds the default value on creation for the "bindType" field. + DefaultBindType string + // BindTypeValidator is a validator for the "bindType" field. It is called by the builders before save. + BindTypeValidator func(string) error + // DefaultOperator holds the default value on creation for the "operator" field. + DefaultOperator string + // OperatorValidator is a validator for the "operator" field. It is called by the builders before save. + OperatorValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "createdAt" field. + DefaultCreatedAt func() time.Time + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int) error +) + +// OrderOption defines the ordering options for the WorkpieceBind queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// BySn orders the results by the sn field. +func BySn(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSn, opts...).ToFunc() +} + +// ByOrderNo orders the results by the orderNo field. +func ByOrderNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrderNo, opts...).ToFunc() +} + +// ByProcessCode orders the results by the processCode field. +func ByProcessCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProcessCode, opts...).ToFunc() +} + +// ByStationNo orders the results by the stationNo field. +func ByStationNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStationNo, opts...).ToFunc() +} + +// ByMaterialCode orders the results by the materialCode field. +func ByMaterialCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMaterialCode, opts...).ToFunc() +} + +// ByMaterialName orders the results by the materialName field. +func ByMaterialName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMaterialName, opts...).ToFunc() +} + +// BySpec orders the results by the spec field. +func BySpec(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpec, opts...).ToFunc() +} + +// ByUnit orders the results by the unit field. +func ByUnit(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUnit, opts...).ToFunc() +} + +// ByManageMode orders the results by the manageMode field. +func ByManageMode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldManageMode, opts...).ToFunc() +} + +// ByBindValue orders the results by the bindValue field. +func ByBindValue(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBindValue, opts...).ToFunc() +} + +// ByBindType orders the results by the bindType field. +func ByBindType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBindType, opts...).ToFunc() +} + +// ByOperator orders the results by the operator field. +func ByOperator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOperator, opts...).ToFunc() +} + +// ByCreatedAt orders the results by the createdAt field. +func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() +} diff --git a/bj_power_mes/ent/workpiecebind_create.go b/bj_power_mes/ent/workpiecebind_create.go new file mode 100644 index 0000000..c9096f8 --- /dev/null +++ b/bj_power_mes/ent/workpiecebind_create.go @@ -0,0 +1,526 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/workpiecebind" + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkpieceBindCreate is the builder for creating a WorkpieceBind entity. +type WorkpieceBindCreate struct { + config + mutation *WorkpieceBindMutation + hooks []Hook +} + +// SetSn sets the "sn" field. +func (_c *WorkpieceBindCreate) SetSn(v string) *WorkpieceBindCreate { + _c.mutation.SetSn(v) + return _c +} + +// SetOrderNo sets the "orderNo" field. +func (_c *WorkpieceBindCreate) SetOrderNo(v string) *WorkpieceBindCreate { + _c.mutation.SetOrderNo(v) + return _c +} + +// SetNillableOrderNo sets the "orderNo" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableOrderNo(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetOrderNo(*v) + } + return _c +} + +// SetProcessCode sets the "processCode" field. +func (_c *WorkpieceBindCreate) SetProcessCode(v int) *WorkpieceBindCreate { + _c.mutation.SetProcessCode(v) + return _c +} + +// SetStationNo sets the "stationNo" field. +func (_c *WorkpieceBindCreate) SetStationNo(v string) *WorkpieceBindCreate { + _c.mutation.SetStationNo(v) + return _c +} + +// SetNillableStationNo sets the "stationNo" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableStationNo(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetStationNo(*v) + } + return _c +} + +// SetMaterialCode sets the "materialCode" field. +func (_c *WorkpieceBindCreate) SetMaterialCode(v string) *WorkpieceBindCreate { + _c.mutation.SetMaterialCode(v) + return _c +} + +// SetMaterialName sets the "materialName" field. +func (_c *WorkpieceBindCreate) SetMaterialName(v string) *WorkpieceBindCreate { + _c.mutation.SetMaterialName(v) + return _c +} + +// SetNillableMaterialName sets the "materialName" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableMaterialName(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetMaterialName(*v) + } + return _c +} + +// SetSpec sets the "spec" field. +func (_c *WorkpieceBindCreate) SetSpec(v string) *WorkpieceBindCreate { + _c.mutation.SetSpec(v) + return _c +} + +// SetNillableSpec sets the "spec" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableSpec(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetSpec(*v) + } + return _c +} + +// SetUnit sets the "unit" field. +func (_c *WorkpieceBindCreate) SetUnit(v string) *WorkpieceBindCreate { + _c.mutation.SetUnit(v) + return _c +} + +// SetNillableUnit sets the "unit" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableUnit(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetUnit(*v) + } + return _c +} + +// SetManageMode sets the "manageMode" field. +func (_c *WorkpieceBindCreate) SetManageMode(v string) *WorkpieceBindCreate { + _c.mutation.SetManageMode(v) + return _c +} + +// SetNillableManageMode sets the "manageMode" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableManageMode(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetManageMode(*v) + } + return _c +} + +// SetBindValue sets the "bindValue" field. +func (_c *WorkpieceBindCreate) SetBindValue(v string) *WorkpieceBindCreate { + _c.mutation.SetBindValue(v) + return _c +} + +// SetBindType sets the "bindType" field. +func (_c *WorkpieceBindCreate) SetBindType(v string) *WorkpieceBindCreate { + _c.mutation.SetBindType(v) + return _c +} + +// SetNillableBindType sets the "bindType" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableBindType(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetBindType(*v) + } + return _c +} + +// SetOperator sets the "operator" field. +func (_c *WorkpieceBindCreate) SetOperator(v string) *WorkpieceBindCreate { + _c.mutation.SetOperator(v) + return _c +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableOperator(v *string) *WorkpieceBindCreate { + if v != nil { + _c.SetOperator(*v) + } + return _c +} + +// SetCreatedAt sets the "createdAt" field. +func (_c *WorkpieceBindCreate) SetCreatedAt(v time.Time) *WorkpieceBindCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil. +func (_c *WorkpieceBindCreate) SetNillableCreatedAt(v *time.Time) *WorkpieceBindCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *WorkpieceBindCreate) SetID(v int) *WorkpieceBindCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the WorkpieceBindMutation object of the builder. +func (_c *WorkpieceBindCreate) Mutation() *WorkpieceBindMutation { + return _c.mutation +} + +// Save creates the WorkpieceBind in the database. +func (_c *WorkpieceBindCreate) Save(ctx context.Context) (*WorkpieceBind, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *WorkpieceBindCreate) SaveX(ctx context.Context) *WorkpieceBind { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *WorkpieceBindCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *WorkpieceBindCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *WorkpieceBindCreate) defaults() { + if _, ok := _c.mutation.OrderNo(); !ok { + v := workpiecebind.DefaultOrderNo + _c.mutation.SetOrderNo(v) + } + if _, ok := _c.mutation.StationNo(); !ok { + v := workpiecebind.DefaultStationNo + _c.mutation.SetStationNo(v) + } + if _, ok := _c.mutation.MaterialName(); !ok { + v := workpiecebind.DefaultMaterialName + _c.mutation.SetMaterialName(v) + } + if _, ok := _c.mutation.Spec(); !ok { + v := workpiecebind.DefaultSpec + _c.mutation.SetSpec(v) + } + if _, ok := _c.mutation.Unit(); !ok { + v := workpiecebind.DefaultUnit + _c.mutation.SetUnit(v) + } + if _, ok := _c.mutation.ManageMode(); !ok { + v := workpiecebind.DefaultManageMode + _c.mutation.SetManageMode(v) + } + if _, ok := _c.mutation.BindType(); !ok { + v := workpiecebind.DefaultBindType + _c.mutation.SetBindType(v) + } + if _, ok := _c.mutation.Operator(); !ok { + v := workpiecebind.DefaultOperator + _c.mutation.SetOperator(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := workpiecebind.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *WorkpieceBindCreate) check() error { + if _, ok := _c.mutation.Sn(); !ok { + return &ValidationError{Name: "sn", err: errors.New(`ent: missing required field "WorkpieceBind.sn"`)} + } + if v, ok := _c.mutation.Sn(); ok { + if err := workpiecebind.SnValidator(v); err != nil { + return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.sn": %w`, err)} + } + } + if _, ok := _c.mutation.OrderNo(); !ok { + return &ValidationError{Name: "orderNo", err: errors.New(`ent: missing required field "WorkpieceBind.orderNo"`)} + } + if v, ok := _c.mutation.OrderNo(); ok { + if err := workpiecebind.OrderNoValidator(v); err != nil { + return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.orderNo": %w`, err)} + } + } + if _, ok := _c.mutation.ProcessCode(); !ok { + return &ValidationError{Name: "processCode", err: errors.New(`ent: missing required field "WorkpieceBind.processCode"`)} + } + if _, ok := _c.mutation.StationNo(); !ok { + return &ValidationError{Name: "stationNo", err: errors.New(`ent: missing required field "WorkpieceBind.stationNo"`)} + } + if v, ok := _c.mutation.StationNo(); ok { + if err := workpiecebind.StationNoValidator(v); err != nil { + return &ValidationError{Name: "stationNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.stationNo": %w`, err)} + } + } + if _, ok := _c.mutation.MaterialCode(); !ok { + return &ValidationError{Name: "materialCode", err: errors.New(`ent: missing required field "WorkpieceBind.materialCode"`)} + } + if v, ok := _c.mutation.MaterialCode(); ok { + if err := workpiecebind.MaterialCodeValidator(v); err != nil { + return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.materialCode": %w`, err)} + } + } + if _, ok := _c.mutation.MaterialName(); !ok { + return &ValidationError{Name: "materialName", err: errors.New(`ent: missing required field "WorkpieceBind.materialName"`)} + } + if v, ok := _c.mutation.MaterialName(); ok { + if err := workpiecebind.MaterialNameValidator(v); err != nil { + return &ValidationError{Name: "materialName", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.materialName": %w`, err)} + } + } + if _, ok := _c.mutation.Spec(); !ok { + return &ValidationError{Name: "spec", err: errors.New(`ent: missing required field "WorkpieceBind.spec"`)} + } + if v, ok := _c.mutation.Spec(); ok { + if err := workpiecebind.SpecValidator(v); err != nil { + return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.spec": %w`, err)} + } + } + if _, ok := _c.mutation.Unit(); !ok { + return &ValidationError{Name: "unit", err: errors.New(`ent: missing required field "WorkpieceBind.unit"`)} + } + if v, ok := _c.mutation.Unit(); ok { + if err := workpiecebind.UnitValidator(v); err != nil { + return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.unit": %w`, err)} + } + } + if _, ok := _c.mutation.ManageMode(); !ok { + return &ValidationError{Name: "manageMode", err: errors.New(`ent: missing required field "WorkpieceBind.manageMode"`)} + } + if v, ok := _c.mutation.ManageMode(); ok { + if err := workpiecebind.ManageModeValidator(v); err != nil { + return &ValidationError{Name: "manageMode", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.manageMode": %w`, err)} + } + } + if _, ok := _c.mutation.BindValue(); !ok { + return &ValidationError{Name: "bindValue", err: errors.New(`ent: missing required field "WorkpieceBind.bindValue"`)} + } + if v, ok := _c.mutation.BindValue(); ok { + if err := workpiecebind.BindValueValidator(v); err != nil { + return &ValidationError{Name: "bindValue", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.bindValue": %w`, err)} + } + } + if _, ok := _c.mutation.BindType(); !ok { + return &ValidationError{Name: "bindType", err: errors.New(`ent: missing required field "WorkpieceBind.bindType"`)} + } + if v, ok := _c.mutation.BindType(); ok { + if err := workpiecebind.BindTypeValidator(v); err != nil { + return &ValidationError{Name: "bindType", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.bindType": %w`, err)} + } + } + if _, ok := _c.mutation.Operator(); !ok { + return &ValidationError{Name: "operator", err: errors.New(`ent: missing required field "WorkpieceBind.operator"`)} + } + if v, ok := _c.mutation.Operator(); ok { + if err := workpiecebind.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.operator": %w`, err)} + } + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "WorkpieceBind.createdAt"`)} + } + if v, ok := _c.mutation.ID(); ok { + if err := workpiecebind.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.id": %w`, err)} + } + } + return nil +} + +func (_c *WorkpieceBindCreate) sqlSave(ctx context.Context) (*WorkpieceBind, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *WorkpieceBindCreate) createSpec() (*WorkpieceBind, *sqlgraph.CreateSpec) { + var ( + _node = &WorkpieceBind{config: _c.config} + _spec = sqlgraph.NewCreateSpec(workpiecebind.Table, sqlgraph.NewFieldSpec(workpiecebind.FieldID, field.TypeInt)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.Sn(); ok { + _spec.SetField(workpiecebind.FieldSn, field.TypeString, value) + _node.Sn = value + } + if value, ok := _c.mutation.OrderNo(); ok { + _spec.SetField(workpiecebind.FieldOrderNo, field.TypeString, value) + _node.OrderNo = value + } + if value, ok := _c.mutation.ProcessCode(); ok { + _spec.SetField(workpiecebind.FieldProcessCode, field.TypeInt, value) + _node.ProcessCode = value + } + if value, ok := _c.mutation.StationNo(); ok { + _spec.SetField(workpiecebind.FieldStationNo, field.TypeString, value) + _node.StationNo = value + } + if value, ok := _c.mutation.MaterialCode(); ok { + _spec.SetField(workpiecebind.FieldMaterialCode, field.TypeString, value) + _node.MaterialCode = value + } + if value, ok := _c.mutation.MaterialName(); ok { + _spec.SetField(workpiecebind.FieldMaterialName, field.TypeString, value) + _node.MaterialName = value + } + if value, ok := _c.mutation.Spec(); ok { + _spec.SetField(workpiecebind.FieldSpec, field.TypeString, value) + _node.Spec = value + } + if value, ok := _c.mutation.Unit(); ok { + _spec.SetField(workpiecebind.FieldUnit, field.TypeString, value) + _node.Unit = value + } + if value, ok := _c.mutation.ManageMode(); ok { + _spec.SetField(workpiecebind.FieldManageMode, field.TypeString, value) + _node.ManageMode = value + } + if value, ok := _c.mutation.BindValue(); ok { + _spec.SetField(workpiecebind.FieldBindValue, field.TypeString, value) + _node.BindValue = value + } + if value, ok := _c.mutation.BindType(); ok { + _spec.SetField(workpiecebind.FieldBindType, field.TypeString, value) + _node.BindType = value + } + if value, ok := _c.mutation.Operator(); ok { + _spec.SetField(workpiecebind.FieldOperator, field.TypeString, value) + _node.Operator = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(workpiecebind.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + return _node, _spec +} + +// WorkpieceBindCreateBulk is the builder for creating many WorkpieceBind entities in bulk. +type WorkpieceBindCreateBulk struct { + config + err error + builders []*WorkpieceBindCreate +} + +// Save creates the WorkpieceBind entities in the database. +func (_c *WorkpieceBindCreateBulk) Save(ctx context.Context) ([]*WorkpieceBind, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*WorkpieceBind, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WorkpieceBindMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *WorkpieceBindCreateBulk) SaveX(ctx context.Context) []*WorkpieceBind { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *WorkpieceBindCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *WorkpieceBindCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/workpiecebind_delete.go b/bj_power_mes/ent/workpiecebind_delete.go new file mode 100644 index 0000000..4f898b4 --- /dev/null +++ b/bj_power_mes/ent/workpiecebind_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/predicate" + "bj_power_mes/ent/workpiecebind" + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkpieceBindDelete is the builder for deleting a WorkpieceBind entity. +type WorkpieceBindDelete struct { + config + hooks []Hook + mutation *WorkpieceBindMutation +} + +// Where appends a list predicates to the WorkpieceBindDelete builder. +func (_d *WorkpieceBindDelete) Where(ps ...predicate.WorkpieceBind) *WorkpieceBindDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *WorkpieceBindDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *WorkpieceBindDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *WorkpieceBindDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(workpiecebind.Table, sqlgraph.NewFieldSpec(workpiecebind.FieldID, field.TypeInt)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// WorkpieceBindDeleteOne is the builder for deleting a single WorkpieceBind entity. +type WorkpieceBindDeleteOne struct { + _d *WorkpieceBindDelete +} + +// Where appends a list predicates to the WorkpieceBindDelete builder. +func (_d *WorkpieceBindDeleteOne) Where(ps ...predicate.WorkpieceBind) *WorkpieceBindDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *WorkpieceBindDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{workpiecebind.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *WorkpieceBindDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/workpiecebind_query.go b/bj_power_mes/ent/workpiecebind_query.go new file mode 100644 index 0000000..c955a06 --- /dev/null +++ b/bj_power_mes/ent/workpiecebind_query.go @@ -0,0 +1,577 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/predicate" + "bj_power_mes/ent/workpiecebind" + "context" + "fmt" + "math" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkpieceBindQuery is the builder for querying WorkpieceBind entities. +type WorkpieceBindQuery struct { + config + ctx *QueryContext + order []workpiecebind.OrderOption + inters []Interceptor + predicates []predicate.WorkpieceBind + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the WorkpieceBindQuery builder. +func (_q *WorkpieceBindQuery) Where(ps ...predicate.WorkpieceBind) *WorkpieceBindQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *WorkpieceBindQuery) Limit(limit int) *WorkpieceBindQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *WorkpieceBindQuery) Offset(offset int) *WorkpieceBindQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *WorkpieceBindQuery) Unique(unique bool) *WorkpieceBindQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *WorkpieceBindQuery) Order(o ...workpiecebind.OrderOption) *WorkpieceBindQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first WorkpieceBind entity from the query. +// Returns a *NotFoundError when no WorkpieceBind was found. +func (_q *WorkpieceBindQuery) First(ctx context.Context) (*WorkpieceBind, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{workpiecebind.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *WorkpieceBindQuery) FirstX(ctx context.Context) *WorkpieceBind { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first WorkpieceBind ID from the query. +// Returns a *NotFoundError when no WorkpieceBind ID was found. +func (_q *WorkpieceBindQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{workpiecebind.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *WorkpieceBindQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single WorkpieceBind entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one WorkpieceBind entity is found. +// Returns a *NotFoundError when no WorkpieceBind entities are found. +func (_q *WorkpieceBindQuery) Only(ctx context.Context) (*WorkpieceBind, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{workpiecebind.Label} + default: + return nil, &NotSingularError{workpiecebind.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *WorkpieceBindQuery) OnlyX(ctx context.Context) *WorkpieceBind { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only WorkpieceBind ID in the query. +// Returns a *NotSingularError when more than one WorkpieceBind ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *WorkpieceBindQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{workpiecebind.Label} + default: + err = &NotSingularError{workpiecebind.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *WorkpieceBindQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of WorkpieceBinds. +func (_q *WorkpieceBindQuery) All(ctx context.Context) ([]*WorkpieceBind, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*WorkpieceBind, *WorkpieceBindQuery]() + return withInterceptors[[]*WorkpieceBind](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *WorkpieceBindQuery) AllX(ctx context.Context) []*WorkpieceBind { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of WorkpieceBind IDs. +func (_q *WorkpieceBindQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(workpiecebind.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *WorkpieceBindQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *WorkpieceBindQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*WorkpieceBindQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *WorkpieceBindQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *WorkpieceBindQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *WorkpieceBindQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the WorkpieceBindQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *WorkpieceBindQuery) Clone() *WorkpieceBindQuery { + if _q == nil { + return nil + } + return &WorkpieceBindQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]workpiecebind.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.WorkpieceBind{}, _q.predicates...), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Sn string `json:"sn,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.WorkpieceBind.Query(). +// GroupBy(workpiecebind.FieldSn). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *WorkpieceBindQuery) GroupBy(field string, fields ...string) *WorkpieceBindGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &WorkpieceBindGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = workpiecebind.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Sn string `json:"sn,omitempty"` +// } +// +// client.WorkpieceBind.Query(). +// Select(workpiecebind.FieldSn). +// Scan(ctx, &v) +func (_q *WorkpieceBindQuery) Select(fields ...string) *WorkpieceBindSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &WorkpieceBindSelect{WorkpieceBindQuery: _q} + sbuild.label = workpiecebind.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a WorkpieceBindSelect configured with the given aggregations. +func (_q *WorkpieceBindQuery) Aggregate(fns ...AggregateFunc) *WorkpieceBindSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *WorkpieceBindQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !workpiecebind.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *WorkpieceBindQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*WorkpieceBind, error) { + var ( + nodes = []*WorkpieceBind{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*WorkpieceBind).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &WorkpieceBind{config: _q.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (_q *WorkpieceBindQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *WorkpieceBindQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(workpiecebind.Table, workpiecebind.Columns, sqlgraph.NewFieldSpec(workpiecebind.FieldID, field.TypeInt)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, workpiecebind.FieldID) + for i := range fields { + if fields[i] != workpiecebind.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *WorkpieceBindQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(workpiecebind.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = workpiecebind.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *WorkpieceBindQuery) ForUpdate(opts ...sql.LockOption) *WorkpieceBindQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *WorkpieceBindQuery) ForShare(opts ...sql.LockOption) *WorkpieceBindQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *WorkpieceBindQuery) Modify(modifiers ...func(s *sql.Selector)) *WorkpieceBindSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// WorkpieceBindGroupBy is the group-by builder for WorkpieceBind entities. +type WorkpieceBindGroupBy struct { + selector + build *WorkpieceBindQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *WorkpieceBindGroupBy) Aggregate(fns ...AggregateFunc) *WorkpieceBindGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *WorkpieceBindGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*WorkpieceBindQuery, *WorkpieceBindGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *WorkpieceBindGroupBy) sqlScan(ctx context.Context, root *WorkpieceBindQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// WorkpieceBindSelect is the builder for selecting fields of WorkpieceBind entities. +type WorkpieceBindSelect struct { + *WorkpieceBindQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *WorkpieceBindSelect) Aggregate(fns ...AggregateFunc) *WorkpieceBindSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *WorkpieceBindSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*WorkpieceBindQuery, *WorkpieceBindSelect](ctx, _s.WorkpieceBindQuery, _s, _s.inters, v) +} + +func (_s *WorkpieceBindSelect) sqlScan(ctx context.Context, root *WorkpieceBindQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *WorkpieceBindSelect) Modify(modifiers ...func(s *sql.Selector)) *WorkpieceBindSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/bj_power_mes/ent/workpiecebind_update.go b/bj_power_mes/ent/workpiecebind_update.go new file mode 100644 index 0000000..694a3be --- /dev/null +++ b/bj_power_mes/ent/workpiecebind_update.go @@ -0,0 +1,745 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/predicate" + "bj_power_mes/ent/workpiecebind" + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// WorkpieceBindUpdate is the builder for updating WorkpieceBind entities. +type WorkpieceBindUpdate struct { + config + hooks []Hook + mutation *WorkpieceBindMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the WorkpieceBindUpdate builder. +func (_u *WorkpieceBindUpdate) Where(ps ...predicate.WorkpieceBind) *WorkpieceBindUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetSn sets the "sn" field. +func (_u *WorkpieceBindUpdate) SetSn(v string) *WorkpieceBindUpdate { + _u.mutation.SetSn(v) + return _u +} + +// SetNillableSn sets the "sn" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableSn(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetSn(*v) + } + return _u +} + +// SetOrderNo sets the "orderNo" field. +func (_u *WorkpieceBindUpdate) SetOrderNo(v string) *WorkpieceBindUpdate { + _u.mutation.SetOrderNo(v) + return _u +} + +// SetNillableOrderNo sets the "orderNo" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableOrderNo(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetOrderNo(*v) + } + return _u +} + +// SetProcessCode sets the "processCode" field. +func (_u *WorkpieceBindUpdate) SetProcessCode(v int) *WorkpieceBindUpdate { + _u.mutation.ResetProcessCode() + _u.mutation.SetProcessCode(v) + return _u +} + +// SetNillableProcessCode sets the "processCode" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableProcessCode(v *int) *WorkpieceBindUpdate { + if v != nil { + _u.SetProcessCode(*v) + } + return _u +} + +// AddProcessCode adds value to the "processCode" field. +func (_u *WorkpieceBindUpdate) AddProcessCode(v int) *WorkpieceBindUpdate { + _u.mutation.AddProcessCode(v) + return _u +} + +// SetStationNo sets the "stationNo" field. +func (_u *WorkpieceBindUpdate) SetStationNo(v string) *WorkpieceBindUpdate { + _u.mutation.SetStationNo(v) + return _u +} + +// SetNillableStationNo sets the "stationNo" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableStationNo(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetStationNo(*v) + } + return _u +} + +// SetMaterialCode sets the "materialCode" field. +func (_u *WorkpieceBindUpdate) SetMaterialCode(v string) *WorkpieceBindUpdate { + _u.mutation.SetMaterialCode(v) + return _u +} + +// SetNillableMaterialCode sets the "materialCode" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableMaterialCode(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetMaterialCode(*v) + } + return _u +} + +// SetMaterialName sets the "materialName" field. +func (_u *WorkpieceBindUpdate) SetMaterialName(v string) *WorkpieceBindUpdate { + _u.mutation.SetMaterialName(v) + return _u +} + +// SetNillableMaterialName sets the "materialName" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableMaterialName(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetMaterialName(*v) + } + return _u +} + +// SetSpec sets the "spec" field. +func (_u *WorkpieceBindUpdate) SetSpec(v string) *WorkpieceBindUpdate { + _u.mutation.SetSpec(v) + return _u +} + +// SetNillableSpec sets the "spec" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableSpec(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetSpec(*v) + } + return _u +} + +// SetUnit sets the "unit" field. +func (_u *WorkpieceBindUpdate) SetUnit(v string) *WorkpieceBindUpdate { + _u.mutation.SetUnit(v) + return _u +} + +// SetNillableUnit sets the "unit" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableUnit(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetUnit(*v) + } + return _u +} + +// SetManageMode sets the "manageMode" field. +func (_u *WorkpieceBindUpdate) SetManageMode(v string) *WorkpieceBindUpdate { + _u.mutation.SetManageMode(v) + return _u +} + +// SetNillableManageMode sets the "manageMode" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableManageMode(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetManageMode(*v) + } + return _u +} + +// SetBindValue sets the "bindValue" field. +func (_u *WorkpieceBindUpdate) SetBindValue(v string) *WorkpieceBindUpdate { + _u.mutation.SetBindValue(v) + return _u +} + +// SetNillableBindValue sets the "bindValue" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableBindValue(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetBindValue(*v) + } + return _u +} + +// SetBindType sets the "bindType" field. +func (_u *WorkpieceBindUpdate) SetBindType(v string) *WorkpieceBindUpdate { + _u.mutation.SetBindType(v) + return _u +} + +// SetNillableBindType sets the "bindType" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableBindType(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetBindType(*v) + } + return _u +} + +// SetOperator sets the "operator" field. +func (_u *WorkpieceBindUpdate) SetOperator(v string) *WorkpieceBindUpdate { + _u.mutation.SetOperator(v) + return _u +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_u *WorkpieceBindUpdate) SetNillableOperator(v *string) *WorkpieceBindUpdate { + if v != nil { + _u.SetOperator(*v) + } + return _u +} + +// Mutation returns the WorkpieceBindMutation object of the builder. +func (_u *WorkpieceBindUpdate) Mutation() *WorkpieceBindMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *WorkpieceBindUpdate) 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 *WorkpieceBindUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *WorkpieceBindUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *WorkpieceBindUpdate) 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 *WorkpieceBindUpdate) check() error { + if v, ok := _u.mutation.Sn(); ok { + if err := workpiecebind.SnValidator(v); err != nil { + return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.sn": %w`, err)} + } + } + if v, ok := _u.mutation.OrderNo(); ok { + if err := workpiecebind.OrderNoValidator(v); err != nil { + return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.orderNo": %w`, err)} + } + } + if v, ok := _u.mutation.StationNo(); ok { + if err := workpiecebind.StationNoValidator(v); err != nil { + return &ValidationError{Name: "stationNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.stationNo": %w`, err)} + } + } + if v, ok := _u.mutation.MaterialCode(); ok { + if err := workpiecebind.MaterialCodeValidator(v); err != nil { + return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.materialCode": %w`, err)} + } + } + if v, ok := _u.mutation.MaterialName(); ok { + if err := workpiecebind.MaterialNameValidator(v); err != nil { + return &ValidationError{Name: "materialName", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.materialName": %w`, err)} + } + } + if v, ok := _u.mutation.Spec(); ok { + if err := workpiecebind.SpecValidator(v); err != nil { + return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.spec": %w`, err)} + } + } + if v, ok := _u.mutation.Unit(); ok { + if err := workpiecebind.UnitValidator(v); err != nil { + return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.unit": %w`, err)} + } + } + if v, ok := _u.mutation.ManageMode(); ok { + if err := workpiecebind.ManageModeValidator(v); err != nil { + return &ValidationError{Name: "manageMode", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.manageMode": %w`, err)} + } + } + if v, ok := _u.mutation.BindValue(); ok { + if err := workpiecebind.BindValueValidator(v); err != nil { + return &ValidationError{Name: "bindValue", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.bindValue": %w`, err)} + } + } + if v, ok := _u.mutation.BindType(); ok { + if err := workpiecebind.BindTypeValidator(v); err != nil { + return &ValidationError{Name: "bindType", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.bindType": %w`, err)} + } + } + if v, ok := _u.mutation.Operator(); ok { + if err := workpiecebind.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.operator": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *WorkpieceBindUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkpieceBindUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *WorkpieceBindUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(workpiecebind.Table, workpiecebind.Columns, sqlgraph.NewFieldSpec(workpiecebind.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(workpiecebind.FieldSn, field.TypeString, value) + } + if value, ok := _u.mutation.OrderNo(); ok { + _spec.SetField(workpiecebind.FieldOrderNo, field.TypeString, value) + } + if value, ok := _u.mutation.ProcessCode(); ok { + _spec.SetField(workpiecebind.FieldProcessCode, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProcessCode(); ok { + _spec.AddField(workpiecebind.FieldProcessCode, field.TypeInt, value) + } + if value, ok := _u.mutation.StationNo(); ok { + _spec.SetField(workpiecebind.FieldStationNo, field.TypeString, value) + } + if value, ok := _u.mutation.MaterialCode(); ok { + _spec.SetField(workpiecebind.FieldMaterialCode, field.TypeString, value) + } + if value, ok := _u.mutation.MaterialName(); ok { + _spec.SetField(workpiecebind.FieldMaterialName, field.TypeString, value) + } + if value, ok := _u.mutation.Spec(); ok { + _spec.SetField(workpiecebind.FieldSpec, field.TypeString, value) + } + if value, ok := _u.mutation.Unit(); ok { + _spec.SetField(workpiecebind.FieldUnit, field.TypeString, value) + } + if value, ok := _u.mutation.ManageMode(); ok { + _spec.SetField(workpiecebind.FieldManageMode, field.TypeString, value) + } + if value, ok := _u.mutation.BindValue(); ok { + _spec.SetField(workpiecebind.FieldBindValue, field.TypeString, value) + } + if value, ok := _u.mutation.BindType(); ok { + _spec.SetField(workpiecebind.FieldBindType, field.TypeString, value) + } + if value, ok := _u.mutation.Operator(); ok { + _spec.SetField(workpiecebind.FieldOperator, field.TypeString, value) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{workpiecebind.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// WorkpieceBindUpdateOne is the builder for updating a single WorkpieceBind entity. +type WorkpieceBindUpdateOne struct { + config + fields []string + hooks []Hook + mutation *WorkpieceBindMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetSn sets the "sn" field. +func (_u *WorkpieceBindUpdateOne) SetSn(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetSn(v) + return _u +} + +// SetNillableSn sets the "sn" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableSn(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetSn(*v) + } + return _u +} + +// SetOrderNo sets the "orderNo" field. +func (_u *WorkpieceBindUpdateOne) SetOrderNo(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetOrderNo(v) + return _u +} + +// SetNillableOrderNo sets the "orderNo" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableOrderNo(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetOrderNo(*v) + } + return _u +} + +// SetProcessCode sets the "processCode" field. +func (_u *WorkpieceBindUpdateOne) SetProcessCode(v int) *WorkpieceBindUpdateOne { + _u.mutation.ResetProcessCode() + _u.mutation.SetProcessCode(v) + return _u +} + +// SetNillableProcessCode sets the "processCode" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableProcessCode(v *int) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetProcessCode(*v) + } + return _u +} + +// AddProcessCode adds value to the "processCode" field. +func (_u *WorkpieceBindUpdateOne) AddProcessCode(v int) *WorkpieceBindUpdateOne { + _u.mutation.AddProcessCode(v) + return _u +} + +// SetStationNo sets the "stationNo" field. +func (_u *WorkpieceBindUpdateOne) SetStationNo(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetStationNo(v) + return _u +} + +// SetNillableStationNo sets the "stationNo" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableStationNo(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetStationNo(*v) + } + return _u +} + +// SetMaterialCode sets the "materialCode" field. +func (_u *WorkpieceBindUpdateOne) SetMaterialCode(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetMaterialCode(v) + return _u +} + +// SetNillableMaterialCode sets the "materialCode" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableMaterialCode(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetMaterialCode(*v) + } + return _u +} + +// SetMaterialName sets the "materialName" field. +func (_u *WorkpieceBindUpdateOne) SetMaterialName(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetMaterialName(v) + return _u +} + +// SetNillableMaterialName sets the "materialName" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableMaterialName(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetMaterialName(*v) + } + return _u +} + +// SetSpec sets the "spec" field. +func (_u *WorkpieceBindUpdateOne) SetSpec(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetSpec(v) + return _u +} + +// SetNillableSpec sets the "spec" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableSpec(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetSpec(*v) + } + return _u +} + +// SetUnit sets the "unit" field. +func (_u *WorkpieceBindUpdateOne) SetUnit(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetUnit(v) + return _u +} + +// SetNillableUnit sets the "unit" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableUnit(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetUnit(*v) + } + return _u +} + +// SetManageMode sets the "manageMode" field. +func (_u *WorkpieceBindUpdateOne) SetManageMode(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetManageMode(v) + return _u +} + +// SetNillableManageMode sets the "manageMode" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableManageMode(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetManageMode(*v) + } + return _u +} + +// SetBindValue sets the "bindValue" field. +func (_u *WorkpieceBindUpdateOne) SetBindValue(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetBindValue(v) + return _u +} + +// SetNillableBindValue sets the "bindValue" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableBindValue(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetBindValue(*v) + } + return _u +} + +// SetBindType sets the "bindType" field. +func (_u *WorkpieceBindUpdateOne) SetBindType(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetBindType(v) + return _u +} + +// SetNillableBindType sets the "bindType" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableBindType(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetBindType(*v) + } + return _u +} + +// SetOperator sets the "operator" field. +func (_u *WorkpieceBindUpdateOne) SetOperator(v string) *WorkpieceBindUpdateOne { + _u.mutation.SetOperator(v) + return _u +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_u *WorkpieceBindUpdateOne) SetNillableOperator(v *string) *WorkpieceBindUpdateOne { + if v != nil { + _u.SetOperator(*v) + } + return _u +} + +// Mutation returns the WorkpieceBindMutation object of the builder. +func (_u *WorkpieceBindUpdateOne) Mutation() *WorkpieceBindMutation { + return _u.mutation +} + +// Where appends a list predicates to the WorkpieceBindUpdate builder. +func (_u *WorkpieceBindUpdateOne) Where(ps ...predicate.WorkpieceBind) *WorkpieceBindUpdateOne { + _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 *WorkpieceBindUpdateOne) Select(field string, fields ...string) *WorkpieceBindUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated WorkpieceBind entity. +func (_u *WorkpieceBindUpdateOne) Save(ctx context.Context) (*WorkpieceBind, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *WorkpieceBindUpdateOne) SaveX(ctx context.Context) *WorkpieceBind { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *WorkpieceBindUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *WorkpieceBindUpdateOne) 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 *WorkpieceBindUpdateOne) check() error { + if v, ok := _u.mutation.Sn(); ok { + if err := workpiecebind.SnValidator(v); err != nil { + return &ValidationError{Name: "sn", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.sn": %w`, err)} + } + } + if v, ok := _u.mutation.OrderNo(); ok { + if err := workpiecebind.OrderNoValidator(v); err != nil { + return &ValidationError{Name: "orderNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.orderNo": %w`, err)} + } + } + if v, ok := _u.mutation.StationNo(); ok { + if err := workpiecebind.StationNoValidator(v); err != nil { + return &ValidationError{Name: "stationNo", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.stationNo": %w`, err)} + } + } + if v, ok := _u.mutation.MaterialCode(); ok { + if err := workpiecebind.MaterialCodeValidator(v); err != nil { + return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.materialCode": %w`, err)} + } + } + if v, ok := _u.mutation.MaterialName(); ok { + if err := workpiecebind.MaterialNameValidator(v); err != nil { + return &ValidationError{Name: "materialName", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.materialName": %w`, err)} + } + } + if v, ok := _u.mutation.Spec(); ok { + if err := workpiecebind.SpecValidator(v); err != nil { + return &ValidationError{Name: "spec", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.spec": %w`, err)} + } + } + if v, ok := _u.mutation.Unit(); ok { + if err := workpiecebind.UnitValidator(v); err != nil { + return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.unit": %w`, err)} + } + } + if v, ok := _u.mutation.ManageMode(); ok { + if err := workpiecebind.ManageModeValidator(v); err != nil { + return &ValidationError{Name: "manageMode", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.manageMode": %w`, err)} + } + } + if v, ok := _u.mutation.BindValue(); ok { + if err := workpiecebind.BindValueValidator(v); err != nil { + return &ValidationError{Name: "bindValue", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.bindValue": %w`, err)} + } + } + if v, ok := _u.mutation.BindType(); ok { + if err := workpiecebind.BindTypeValidator(v); err != nil { + return &ValidationError{Name: "bindType", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.bindType": %w`, err)} + } + } + if v, ok := _u.mutation.Operator(); ok { + if err := workpiecebind.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "WorkpieceBind.operator": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *WorkpieceBindUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WorkpieceBindUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *WorkpieceBindUpdateOne) sqlSave(ctx context.Context) (_node *WorkpieceBind, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(workpiecebind.Table, workpiecebind.Columns, sqlgraph.NewFieldSpec(workpiecebind.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "WorkpieceBind.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, workpiecebind.FieldID) + for _, f := range fields { + if !workpiecebind.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != workpiecebind.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(workpiecebind.FieldSn, field.TypeString, value) + } + if value, ok := _u.mutation.OrderNo(); ok { + _spec.SetField(workpiecebind.FieldOrderNo, field.TypeString, value) + } + if value, ok := _u.mutation.ProcessCode(); ok { + _spec.SetField(workpiecebind.FieldProcessCode, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProcessCode(); ok { + _spec.AddField(workpiecebind.FieldProcessCode, field.TypeInt, value) + } + if value, ok := _u.mutation.StationNo(); ok { + _spec.SetField(workpiecebind.FieldStationNo, field.TypeString, value) + } + if value, ok := _u.mutation.MaterialCode(); ok { + _spec.SetField(workpiecebind.FieldMaterialCode, field.TypeString, value) + } + if value, ok := _u.mutation.MaterialName(); ok { + _spec.SetField(workpiecebind.FieldMaterialName, field.TypeString, value) + } + if value, ok := _u.mutation.Spec(); ok { + _spec.SetField(workpiecebind.FieldSpec, field.TypeString, value) + } + if value, ok := _u.mutation.Unit(); ok { + _spec.SetField(workpiecebind.FieldUnit, field.TypeString, value) + } + if value, ok := _u.mutation.ManageMode(); ok { + _spec.SetField(workpiecebind.FieldManageMode, field.TypeString, value) + } + if value, ok := _u.mutation.BindValue(); ok { + _spec.SetField(workpiecebind.FieldBindValue, field.TypeString, value) + } + if value, ok := _u.mutation.BindType(); ok { + _spec.SetField(workpiecebind.FieldBindType, field.TypeString, value) + } + if value, ok := _u.mutation.Operator(); ok { + _spec.SetField(workpiecebind.FieldOperator, field.TypeString, value) + } + _spec.AddModifiers(_u.modifiers...) + _node = &WorkpieceBind{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{workpiecebind.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} diff --git a/bj_power_mes/frontend/src/components/PageHelp.vue b/bj_power_mes/frontend/src/components/PageHelp.vue index 6ac86ef..d2678f9 100644 --- a/bj_power_mes/frontend/src/components/PageHelp.vue +++ b/bj_power_mes/frontend/src/components/PageHelp.vue @@ -1,8 +1,6 @@ - - - - + + {{ data.title || '操作说明' }} @@ -47,22 +45,30 @@ + description="该页面暂未编写操作说明" :image-size="70" /> - diff --git a/bj_power_mes/frontend/src/help.js b/bj_power_mes/frontend/src/help.js index 7d5e488..6773cf2 100644 --- a/bj_power_mes/frontend/src/help.js +++ b/bj_power_mes/frontend/src/help.js @@ -24,16 +24,19 @@ export const helpWorkOrder = { title: '工单管理(新建 / 编辑 / 删除工单)', overview: '工单 = 一个"合同/生产批次"的唯一载体,是生产执行和仓库出库挂靠的核心对象。\n\n全流程:先有产品类型 → 建工单(选产品类型、定数量、勾选工位组合) → 进"物料清单"给该产品配料 → 到"日排产"排哪天产多少 → 仓库按排产备料出库 → 产线装配/拧紧/报工 → 完工。\n工单号会贯穿 备料单、拧紧查询、手动报工、工件追溯、操作日志 全链路。\n\n查询:支持按 工单号 / 产品编码 / 产品名称(模糊) / 状态 组合筛选。\n删除:仅「已创建 / 待排产 / 已发布」且无排产、备料、生产数据的工单可删除(操作列「删除」),生产中或已完成的工单不可删除。', - fields: [ - { name: '工单号', source: '系统自动生成(WO+时间戳),可手工改。新建时自动带出。', purpose: '唯一标识一个工单,备料/出库/报工/追溯都挂在此号下', fill: '一般不用改;如改动须保证唯一' }, - { name: '产品类型', source: '下拉选择。数据来自"产品类型"页面已启用的记录。', purpose: '说明这批生产的是什么产品,并决定物料清单内容', fill: '先到"产品类型"页面建好记录再选择' }, - { name: '产品编码', source: '手工填写。通常与所选产品类型的编码一致。', purpose: '产品唯一编码,用于展示与追溯', fill: '如 METER-01,与产品类型编码对齐' }, - { name: '产品名称', source: '手工填写。通常与产品类型名称一致。', purpose: '产品中文名,用于展示', fill: '如 智能电表' }, - { name: '数量', source: '手工填写整数。', purpose: '本工单生产总数量(合同台数),决定需求量与排产上限', fill: '整数 ≥1,如 100' }, - { name: '工位组合', source: '勾选 12 个工位(工位1~工位12)。', purpose: '本工单要经过的工位集合,PLC 按此组合下发控制产线', fill: '勾选要经过的工位即可,系统自动按 1→12 顺序执行(传送带不回走);半成品再上线可只勾漏做的工位' }, - { name: '状态', source: '新建时选"已创建",后续由流程推进。', purpose: '工单生命周期:创建→发布→生产→完成', fill: '新建时选"已创建";也可在列表操作列点「状态」快捷流转(发布/开工/完工)' } - ], sections: [ + { + title: '工单基本信息', + fields: [ + { name: '工单号', source: '系统自动生成(WO+时间戳),可手工改。新建时自动带出。', purpose: '唯一标识一个工单,备料/出库/报工/追溯都挂在此号下', fill: '一般不用改;如改动须保证唯一' }, + { name: '产品类型', source: '下拉选择。数据来自"产品类型"页面已启用的记录。', purpose: '说明这批生产的是什么产品,并决定物料清单内容', fill: '先到"产品类型"页面建好记录再选择' }, + { name: '产品编码', source: '手工填写。通常与所选产品类型的编码一致。', purpose: '产品唯一编码,用于展示与追溯', fill: '如 METER-01,与产品类型编码对齐' }, + { name: '产品名称', source: '手工填写。通常与产品类型名称一致。', purpose: '产品中文名,用于展示', fill: '如 智能电表' }, + { name: '数量', source: '手工填写整数。', purpose: '本工单生产总数量(合同台数),决定需求量与排产上限', fill: '整数 ≥1,如 100' }, + { name: '工位组合', source: '勾选 12 个工位(工位1~工位12)。', purpose: '本工单要经过的工位集合,PLC 按此组合下发控制产线', fill: '勾选要经过的工位即可,系统自动按 1→12 顺序执行(传送带不回走);半成品再上线可只勾漏做的工位' }, + { name: '状态', source: '新建时选"已创建",后续由流程推进。', purpose: '工单生命周期:创建→发布→生产→完成', fill: '新建时选"已创建";也可在列表操作列点「状态」快捷流转(发布/开工/完工)' } + ] + }, { title: '行内"工位组合"维护', overview: '对当前工单快速维护要经过的工位组合。\n可自由勾选、补工位(半成品再上线):如本应走第3/5工位却做成半成品,可在此只勾第2工位重上线完成闭环。', @@ -215,15 +218,18 @@ export const helpEventLog = { export const helpProcessFlow = { title: '工艺流程(服务于固定工位,含工序步骤)', overview: - '工艺流程 = 某个固定工位(1~12)的作业指导:包含 工位号、工艺图纸PDF、工序步骤(含采集方式与考核标准)。\n\n概念统一说明:\n· 工位:产线固定 12 个物理工位(工位1~工位12),本流程页选择流程服务于哪个工位。\n· 工艺流程:一个流程服务于一个工位,可有多版本(如 3号工位_2026版);一个工位只能有一个「启用」的流程。\n· 工序步骤:流程内包含多个工序步骤(如:装配完成、拧紧扭矩、测试)。\n\n绑定规则:流程选工位号并「启用」后,自动绑定到该工位;「停用」后自动解绑。手动报工页选工位时,自动带出该工位启用流程的工序步骤。\n\n数据链路:本页维护流程+工序步骤+考核标准 → 自动绑定工位 → 手动报工/工位终端按工序步骤采集 → 报工按考核标准自动判 OK/NG → 工件追溯/绩效报表可见。', - fields: [ - { name: '流程名称', source: '手工填写。人为定义。', purpose: '流程版本名,用于区分同一工位的不同版本', fill: '如 3号工位装配流程 / 3号工位_2026版' }, - { name: '工位号', source: '下拉选择(1~12)。产线固定 12 个工位。', purpose: '该流程服务于哪个工位;一个工位只能有一个启用流程', fill: '如 3;该工位已有启用流程时需先停用再启用新流程' }, - { name: '状态', source: '下拉选择 启用/停用。也可在列表操作列点「启用/停用」快捷切换。', purpose: '启用=自动绑定该工位并参与生产;停用=自动解绑工位', fill: '启用后自动绑定工位;停用后自动解绑' }, - { name: '工艺图纸(PDF)', source: '本页上传。文件由 MES 服务器保存。', purpose: '该工位的作业指导图,工位终端打开预览', fill: '选择 PDF 上传,成功后显示文件名可预览' }, - { name: '工序步骤', source: '本页维护(步骤名/采集方式/是否拧紧/考核标准)。', purpose: '手动报工/工位终端报工时按此动态渲染参数输入', fill: '一个流程可含多个工序步骤,按序号顺序执行' } - ], + '页面分「流程列表」「流程配置」两个页签:列表查看全部流程并做启用/停用/删除;配置页维护流程基本信息与工序步骤(新增与编辑共用,不再弹窗套弹窗)。\n\n工艺流程 = 某个固定工位(1~12)的作业指导:包含 工位号、工艺图纸PDF、工序步骤(含采集方式与考核标准)。\n\n概念统一说明:\n· 工位:产线固定 12 个物理工位(工位1~工位12),本流程页选择流程服务于哪个工位。\n· 工艺流程:一个流程服务于一个工位,可有多版本(如 3号工位_2026版);一个工位只能有一个「启用」的流程。\n· 工序步骤:流程内包含多个工序步骤(如:装配完成、拧紧扭矩、测试)。\n\n绑定规则:流程选工位号并「启用」后,自动绑定到该工位;「停用」后自动解绑。手动报工页选工位时,自动带出该工位启用流程的工序步骤。\n\n数据链路:本页维护流程+工序步骤+考核标准 → 自动绑定工位 → 手动报工/工位终端按工序步骤采集 → 报工按考核标准自动判 OK/NG → 工件追溯/绩效报表可见。', sections: [ + { + title: '流程基本信息', + fields: [ + { name: '流程名称', source: '手工填写。人为定义。', purpose: '流程版本名,用于区分同一工位的不同版本', fill: '如 3号工位装配流程 / 3号工位_2026版' }, + { name: '工位号', source: '下拉选择(1~12)。产线固定 12 个工位。', purpose: '该流程服务于哪个工位;一个工位只能有一个启用流程', fill: '如 3;该工位已有启用流程时需先停用再启用新流程' }, + { name: '状态', source: '下拉选择 启用/停用。也可在列表操作列点「启用/停用」快捷切换。', purpose: '启用=自动绑定该工位并参与生产;停用=自动解绑工位', fill: '启用后自动绑定工位;停用后自动解绑' }, + { name: '工艺图纸(PDF)', source: '本页上传。文件由 MES 服务器保存。', purpose: '该工位的作业指导图,工位终端打开预览', fill: '选择 PDF 上传,成功后显示文件名可预览' }, + { name: '工序步骤', source: '本页维护(步骤名/采集方式/是否拧紧/考核标准)。', purpose: '手动报工/工位终端报工时按此动态渲染参数输入', fill: '一个流程可含多个工序步骤,按序号顺序执行' } + ] + }, { title: '采集方式(每个工序步骤三选一)', overview: '决定该步骤的数值从哪里来。', @@ -249,7 +255,7 @@ export const helpProcessFlow = { export const helpPerformance = { title: '绩效报表(工人工作量统计)', overview: - '按 操作人 × 日期 × 工位 汇总每个工人的完成/合格/NG 数量,用于工作量与绩效统计。\n\n数据来源:全部由工位终端/手动报工的「工位完成上报」自动写入报工实绩(workpiece_process),本页只读统计,不手工录入。\n\n数据链路:工位终端报工(写报工实绩) → 本页按人/天/工位聚合 → 出报表。', + '按 操作人 × 日期 × 工位 汇总每个工人的完成/合格/NG 数量,用于工作量与绩效统计。\n\n页面提供「按人 / 按工位 / 明细」三个视图切换:按人看每人汇总,按工位看每工位汇总,明细看逐条记录;三者均受上方筛选条件约束,顶部汇总卡为当前筛选的总计。\n\n数据来源:全部由工位终端/手动报工的「工位完成上报」自动写入报工实绩(workpiece_process),本页只读统计,不手工录入。\n\n数据链路:工位终端报工(写报工实绩) → 本页按人/天/工位聚合 → 出报表。', fields: [ { name: '操作人', source: '筛选条件。来自报工实绩的 operator 字段(工位终端登录人)。', purpose: '只看某个工人的工作量', fill: '输入姓名/账号,可空=全部' }, { name: '日期范围', source: '筛选条件。来自报工实绩的产生时间。', purpose: '按时间段统计', fill: '选择起止日期,可空=全部' }, diff --git a/bj_power_mes/frontend/src/layouts/MainLayout.vue b/bj_power_mes/frontend/src/layouts/MainLayout.vue index 31aa6f4..6834629 100644 --- a/bj_power_mes/frontend/src/layouts/MainLayout.vue +++ b/bj_power_mes/frontend/src/layouts/MainLayout.vue @@ -71,7 +71,7 @@ import request from '../utils/request' const router = useRouter() // ===== 响应式侧边栏:桌面可折叠,移动端抽屉 ===== -const isCollapse = ref(false) // 桌面端折叠(仅图标) +const isCollapse = ref(false) // 桌面端默认展开(汉堡菜单展开态);基础配置/系统管理分组靠 defaultOpeneds 默认收起 const isMobile = ref(false) // 移动端(≤767px) const mobileOpen = ref(false) // 移动端抽屉展开 @@ -149,10 +149,17 @@ const menuGroups = [ } ] -// 默认展开全部分组;折叠→展开时重建菜单使 default-openeds 重新生效 +// 默认展开分组:仅展开高频业务组(生产管理/现场作业); +// 基础配置(用户称"集成配置")、系统管理 默认收起,需手动点开。 +// 折叠→展开时重建菜单使 default-openeds 重新生效 // (Element Plus 折叠会清空内部 openedMenus,default-openeds 仅在初始化时读取一次, // 故用 key 变化强制重建实例 —— 同 WMS 的处理) -const defaultOpeneds = computed(() => menus.value.map((g) => 'group:' + g.title)) +const collapsedGroups = ['基础配置', '系统管理'] +const defaultOpeneds = computed(() => + menus.value + .map((g) => 'group:' + g.title) + .filter((k) => !collapsedGroups.includes(k.replace('group:', ''))) +) const menuKey = ref(0) watch(isCollapse, (collapsed) => { if (!collapsed) menuKey.value++ diff --git a/bj_power_mes/frontend/src/pages/Bom.vue b/bj_power_mes/frontend/src/pages/Bom.vue index 4f94b50..1ff0904 100644 --- a/bj_power_mes/frontend/src/pages/Bom.vue +++ b/bj_power_mes/frontend/src/pages/Bom.vue @@ -21,6 +21,18 @@ {{ row.manageMode === '1' ? '结构件(批次)' : '精密件(SN)' }} + + + + + + + + + 工位{{ row.processCode }} + 未指定 + + @@ -49,6 +61,12 @@ 结构件(批次) + + + + + 该料在第几道工序被装配。指定后,此工序报工/完工时强制校验绑定齐套:精密件按单台用量逐颗扫SN、结构件至少绑一个批次号。 + @@ -62,7 +80,7 @@ - + - + + diff --git a/bj_power_mes/schema/bom_item.go b/bj_power_mes/schema/bom_item.go index 2aa0bca..2a1b030 100644 --- a/bj_power_mes/schema/bom_item.go +++ b/bj_power_mes/schema/bom_item.go @@ -30,6 +30,8 @@ func (BomItem) Fields() []ent.Field { field.String("unit").Default("").MaxLen(16), // 1 批次(结构件) / 2 序列号(精密件) field.String("manageMode").Default("2").MaxLen(10), + // 装配工序 1..12:该料在第几道工序被装配(装机绑定/齐套校验按此过滤);0=未指定,不参与工位绑定校验 + field.Int("processCode").Default(0).Comment("装配工序 1~12,0=不参与工位绑定"), field.Float("unitQty").Default(0).Comment("单台用量"), field.Float("lossRate").Default(0).Comment("损耗率%"), field.Float("requiredQty").Default(0).Comment("需求总量=总台数*单台*(1+损耗)"), diff --git a/bj_power_mes/schema/permission.go b/bj_power_mes/schema/permission.go index 4f8b56b..292226f 100644 --- a/bj_power_mes/schema/permission.go +++ b/bj_power_mes/schema/permission.go @@ -26,6 +26,8 @@ func (Permission) Fields() []ent.Field { field.String("name").MaxLen(64).Comment("名称"), // MENU / BUTTON field.String("type").Default("MENU").MaxLen(20), + // 所属菜单权限码:BUTTON 必填(显式声明挂在哪个菜单下),MENU 为空 + field.String("parentCode").Default("").MaxLen(64).Comment("所属菜单权限码(按钮必填)"), field.String("path").Default("").MaxLen(128).Comment("前端路由"), field.String("icon").Default("").MaxLen(64), field.Int("sort").Default(0).Optional(), diff --git a/bj_power_mes/schema/workpiece_bind.go b/bj_power_mes/schema/workpiece_bind.go new file mode 100644 index 0000000..6277003 --- /dev/null +++ b/bj_power_mes/schema/workpiece_bind.go @@ -0,0 +1,53 @@ +package schema + +import ( + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// WorkpieceBind 装机绑定:某工件在某一工序装配时,把实际装上的部件(结构件=批次号 / 精密件=SN) +// 绑定到工件,构成"这台机实际用了哪些料"的单件追溯。绑定动作在工位扫码/手录产生。 +type WorkpieceBind struct { + ent.Schema +} + +func (WorkpieceBind) Annotations() []schema.Annotation { + return []schema.Annotation{entsql.Annotation{Table: "workpiece_bind"}} +} + +func (WorkpieceBind) Fields() []ent.Field { + return []ent.Field{ + field.Int("id").Positive(), + field.String("sn").MaxLen(64).Comment("工件SN"), + field.String("orderNo").Default("").MaxLen(64).Comment("工单号"), + field.Int("processCode").Comment("装配工序 1~12"), + field.String("stationNo").Default("").MaxLen(32).Comment("绑定工位"), + field.String("materialCode").MaxLen(64).Comment("物料编码"), + field.String("materialName").Default("").MaxLen(128).Comment("物料名称"), + field.String("spec").Default("").MaxLen(128).Comment("规格"), + field.String("unit").Default("").MaxLen(16).Comment("单位"), + // 1 批次(结构件) / 2 序列号(精密件) + field.String("manageMode").Default("2").MaxLen(10), + // 结构件=批次号;精密件=SN 码 + field.String("bindValue").MaxLen(128).Comment("绑定值:批次号 或 SN"), + // BATCH(批次绑定) / SN(序列号绑定),冗余自 manageMode 便于直接展示 + field.String("bindType").Default("SN").MaxLen(10), + field.String("operator").Default("").MaxLen(64).Comment("操作人"), + field.Time("createdAt").Default(time.Now).Immutable().Comment("绑定时间"), + } +} + +func (WorkpieceBind) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("sn"), + index.Fields("sn", "processCode"), + index.Fields("sn", "materialCode"), + index.Fields("orderNo"), + index.Fields("materialCode", "bindValue"), + } +} diff --git a/bj_power_mes/tools/migrateonce/main.go b/bj_power_mes/tools/migrateonce/main.go new file mode 100644 index 0000000..2b10808 --- /dev/null +++ b/bj_power_mes/tools/migrateonce/main.go @@ -0,0 +1,69 @@ +// 一次性运维工具:直接加载项目配置执行 EnsureDB + EnsureSchema(建新表 + 幂等补列), +// 绕过交互式管理员密码门禁(密码留在配置文件内,不落日志、不打印)。 +// 用法:go run ./tools/migrateonce +package main + +import ( + "context" + "fmt" + "os" + + "bj_power_mes/internal/config" + "bj_power_mes/internal/db" + + "github.com/zeromicro/go-zero/core/conf" +) + +func main() { + var c config.Config + conf.MustLoad("etc/bj_power_mes-api.yaml", &c) + + if err := db.EnsureDB(c.Database); err != nil { + fmt.Println("ENSURE_DB_FAIL:", err) + os.Exit(1) + } + client, sqlDB := db.MustNewDB(c.Database) + defer client.Close() + defer sqlDB.Close() + + // 迁移前现状:库名 + 现有表清单 + rows, err := sqlDB.QueryContext(context.Background(), + `SELECT current_database(), COALESCE(string_agg(tablename, ','), '(empty)') FROM pg_tables WHERE schemaname='public'`) + if err == nil && rows.Next() { + var dbname, tables string + _ = rows.Scan(&dbname, &tables) + rows.Close() + fmt.Printf("DB=%s TABLES_BEFORE=%s\n", dbname, tables) + } + + if err := db.EnsureSchema(client, sqlDB); err != nil { + fmt.Println("MIGRATE_FAIL:", err) + os.Exit(1) + } + + // 迁移结果自检:新表存在 + 旧表新列存在 + var tableExists bool + if err := sqlDB.QueryRowContext(context.Background(), + `SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_schema='public' AND table_name='workpiece_bind')`, + ).Scan(&tableExists); err != nil { + fmt.Println("VERIFY_FAIL:", err) + os.Exit(1) + } + var colExists bool + if err := sqlDB.QueryRowContext(context.Background(), + `SELECT EXISTS(SELECT 1 FROM information_schema.columns WHERE table_schema='public' AND table_name='work_order_bom' AND column_name='process_code')`, + ).Scan(&colExists); err != nil { + fmt.Println("VERIFY_FAIL:", err) + os.Exit(1) + } + var bindCols int + _ = sqlDB.QueryRowContext(context.Background(), + `SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='public' AND table_name='workpiece_bind'`, + ).Scan(&bindCols) + + fmt.Printf("MIGRATE_OK workpiece_bind_table=%v bom_item.process_code=%v workpiece_bind_cols=%d\n", + tableExists, colExists, bindCols) + if !tableExists || !colExists { + os.Exit(1) + } +} diff --git a/bj_power_wms_client/frontend/src/help.js b/bj_power_wms_client/frontend/src/help.js index edb91b8..9838556 100644 --- a/bj_power_wms_client/frontend/src/help.js +++ b/bj_power_wms_client/frontend/src/help.js @@ -196,6 +196,22 @@ export const helpDashboard = { overview: '只读看板:库存总量、物料种类、出入库动态等。\n数据实时读取统计接口,本页不可编辑。', fields: [] } +export const helpRole = { + title: '角色管理', + overview: + '角色决定账号能看哪些菜单(勾选菜单)与能用哪些功能(勾选其下按钮),勾选互不影响。\n内置角色:管理员(全部权限)、库房保管员、质检员——不可删除;管理员权限不可编辑。', + sections: [ + { + title: '新增 / 编辑权限', + fields: [ + { name: '角色名称', source: '手工填写。', purpose: '角色中文名', fill: '如 库房管理员' }, + { name: '角色编码', source: '手工填写。', purpose: '角色唯一编码,创建后不可改', fill: '如 intro-manager' }, + { name: '权限树', source: '勾选。来自系统预置的权限菜单与按钮。', purpose: '决定该角色可见菜单与可用按钮', fill: '勾选菜单=可见;勾选按钮=可用(两者独立)' } + ] + } + ] +} + export const helpEventLog = { title: '操作日志', overview: diff --git a/bj_power_wms_client/frontend/src/pages/RoleManage.vue b/bj_power_wms_client/frontend/src/pages/RoleManage.vue index c2703e7..4a74b31 100644 --- a/bj_power_wms_client/frontend/src/pages/RoleManage.vue +++ b/bj_power_wms_client/frontend/src/pages/RoleManage.vue @@ -5,12 +5,21 @@ import { ElMessage, ElMessageBox } from 'element-plus' import request from '../utils/request' import { fmtTime } from '../utils/format' import { can } from '../utils/perm' +import PageHelp from '../components/PageHelp.vue' +import { helpRole } from '../help' const loading = ref(false) const list = ref([]) const perms = ref([]) // 全部权限(MENU + BUTTON) const treeRef = ref() +// 权限码 → 中文名:列表「权限明细」统一显示中文(与 MES 一致) +const codeName = computed(() => { + const m = {} + for (const p of perms.value) m[p.code] = p.name + return m +}) + // 权限树:一级=菜单,二级=该菜单下的按钮;全局按钮(parentCode空)归入「通用」分组 const permTree = computed(() => { const menus = perms.value.filter((p) => p.type === 'MENU') @@ -136,10 +145,13 @@ async function removeRole(row) { } catch { /* 拦截器已提示 */ } } -// 权限码展示(列表内),过长缩略 +// 权限码展示(列表内):统一中文名,最多 8 项,完整内容放 tooltip function permSummary(arr) { - if (!arr || !arr.length) return '-' - return arr.join(', ') + const codes = arr || [] + if (!codes.length) return '-' + if (codes.includes('*')) return '全部权限' + const names = codes.map((c) => codeName.value[c] || c) + return names.length > 8 ? `${names.slice(0, 8).join('、')} 等 ${names.length} 项` : names.join('、') } @@ -166,7 +178,9 @@ function permSummary(arr) { {{ row.remark || '-' }} - {{ (row.permissionCodes || []).length }} 项 + + {{ (row.permissionCodes || []).includes('*') ? '全部' : (row.permissionCodes || []).length }} + @@ -218,6 +232,7 @@ function permSummary(arr) { +