新增扫码中间件支持网络型扫码枪键盘注入,AGV 对接从 WMS 迁至 MES 统一管理;新增拧紧不合格人工处置与 PLC 对账机制,优化退库单关联与工位终端功能,同时清理旧 AGV 任务表,完善数据库与配置项。
516 lines
15 KiB
Go
516 lines
15 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/callpool"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// CallPoolCreate is the builder for creating a CallPool entity.
|
|
type CallPoolCreate struct {
|
|
config
|
|
mutation *CallPoolMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetStationNo sets the "stationNo" field.
|
|
func (_c *CallPoolCreate) SetStationNo(v int) *CallPoolCreate {
|
|
_c.mutation.SetStationNo(v)
|
|
return _c
|
|
}
|
|
|
|
// SetMaterialCode sets the "materialCode" field.
|
|
func (_c *CallPoolCreate) SetMaterialCode(v string) *CallPoolCreate {
|
|
_c.mutation.SetMaterialCode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetMaterialName sets the "materialName" field.
|
|
func (_c *CallPoolCreate) SetMaterialName(v string) *CallPoolCreate {
|
|
_c.mutation.SetMaterialName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableMaterialName sets the "materialName" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableMaterialName(v *string) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetMaterialName(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUnit sets the "unit" field.
|
|
func (_c *CallPoolCreate) SetUnit(v string) *CallPoolCreate {
|
|
_c.mutation.SetUnit(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUnit sets the "unit" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableUnit(v *string) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetUnit(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSnMode sets the "snMode" field.
|
|
func (_c *CallPoolCreate) SetSnMode(v int) *CallPoolCreate {
|
|
_c.mutation.SetSnMode(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSnMode sets the "snMode" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableSnMode(v *int) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetSnMode(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetReqQty sets the "reqQty" field.
|
|
func (_c *CallPoolCreate) SetReqQty(v int) *CallPoolCreate {
|
|
_c.mutation.SetReqQty(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableReqQty sets the "reqQty" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableReqQty(v *int) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetReqQty(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAdjQty sets the "adjQty" field.
|
|
func (_c *CallPoolCreate) SetAdjQty(v int) *CallPoolCreate {
|
|
_c.mutation.SetAdjQty(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableAdjQty sets the "adjQty" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableAdjQty(v *int) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetAdjQty(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSentQty sets the "sentQty" field.
|
|
func (_c *CallPoolCreate) SetSentQty(v int) *CallPoolCreate {
|
|
_c.mutation.SetSentQty(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSentQty sets the "sentQty" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableSentQty(v *int) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetSentQty(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetReservedQty sets the "reservedQty" field.
|
|
func (_c *CallPoolCreate) SetReservedQty(v int) *CallPoolCreate {
|
|
_c.mutation.SetReservedQty(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableReservedQty sets the "reservedQty" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableReservedQty(v *int) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetReservedQty(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCrossDay sets the "crossDay" field.
|
|
func (_c *CallPoolCreate) SetCrossDay(v bool) *CallPoolCreate {
|
|
_c.mutation.SetCrossDay(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCrossDay sets the "crossDay" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableCrossDay(v *bool) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetCrossDay(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPlanDates sets the "planDates" field.
|
|
func (_c *CallPoolCreate) SetPlanDates(v string) *CallPoolCreate {
|
|
_c.mutation.SetPlanDates(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePlanDates sets the "planDates" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillablePlanDates(v *string) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetPlanDates(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "createdAt" field.
|
|
func (_c *CallPoolCreate) SetCreatedAt(v time.Time) *CallPoolCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableCreatedAt(v *time.Time) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updatedAt" field.
|
|
func (_c *CallPoolCreate) SetUpdatedAt(v time.Time) *CallPoolCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updatedAt" field if the given value is not nil.
|
|
func (_c *CallPoolCreate) SetNillableUpdatedAt(v *time.Time) *CallPoolCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *CallPoolCreate) SetID(v int) *CallPoolCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the CallPoolMutation object of the builder.
|
|
func (_c *CallPoolCreate) Mutation() *CallPoolMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the CallPool in the database.
|
|
func (_c *CallPoolCreate) Save(ctx context.Context) (*CallPool, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *CallPoolCreate) SaveX(ctx context.Context) *CallPool {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *CallPoolCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *CallPoolCreate) 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 *CallPoolCreate) defaults() {
|
|
if _, ok := _c.mutation.MaterialName(); !ok {
|
|
v := callpool.DefaultMaterialName
|
|
_c.mutation.SetMaterialName(v)
|
|
}
|
|
if _, ok := _c.mutation.Unit(); !ok {
|
|
v := callpool.DefaultUnit
|
|
_c.mutation.SetUnit(v)
|
|
}
|
|
if _, ok := _c.mutation.SnMode(); !ok {
|
|
v := callpool.DefaultSnMode
|
|
_c.mutation.SetSnMode(v)
|
|
}
|
|
if _, ok := _c.mutation.ReqQty(); !ok {
|
|
v := callpool.DefaultReqQty
|
|
_c.mutation.SetReqQty(v)
|
|
}
|
|
if _, ok := _c.mutation.AdjQty(); !ok {
|
|
v := callpool.DefaultAdjQty
|
|
_c.mutation.SetAdjQty(v)
|
|
}
|
|
if _, ok := _c.mutation.SentQty(); !ok {
|
|
v := callpool.DefaultSentQty
|
|
_c.mutation.SetSentQty(v)
|
|
}
|
|
if _, ok := _c.mutation.ReservedQty(); !ok {
|
|
v := callpool.DefaultReservedQty
|
|
_c.mutation.SetReservedQty(v)
|
|
}
|
|
if _, ok := _c.mutation.CrossDay(); !ok {
|
|
v := callpool.DefaultCrossDay
|
|
_c.mutation.SetCrossDay(v)
|
|
}
|
|
if _, ok := _c.mutation.PlanDates(); !ok {
|
|
v := callpool.DefaultPlanDates
|
|
_c.mutation.SetPlanDates(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := callpool.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
v := callpool.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *CallPoolCreate) check() error {
|
|
if _, ok := _c.mutation.StationNo(); !ok {
|
|
return &ValidationError{Name: "stationNo", err: errors.New(`ent: missing required field "CallPool.stationNo"`)}
|
|
}
|
|
if _, ok := _c.mutation.MaterialCode(); !ok {
|
|
return &ValidationError{Name: "materialCode", err: errors.New(`ent: missing required field "CallPool.materialCode"`)}
|
|
}
|
|
if v, ok := _c.mutation.MaterialCode(); ok {
|
|
if err := callpool.MaterialCodeValidator(v); err != nil {
|
|
return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "CallPool.materialCode": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.MaterialName(); !ok {
|
|
return &ValidationError{Name: "materialName", err: errors.New(`ent: missing required field "CallPool.materialName"`)}
|
|
}
|
|
if v, ok := _c.mutation.MaterialName(); ok {
|
|
if err := callpool.MaterialNameValidator(v); err != nil {
|
|
return &ValidationError{Name: "materialName", err: fmt.Errorf(`ent: validator failed for field "CallPool.materialName": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Unit(); !ok {
|
|
return &ValidationError{Name: "unit", err: errors.New(`ent: missing required field "CallPool.unit"`)}
|
|
}
|
|
if v, ok := _c.mutation.Unit(); ok {
|
|
if err := callpool.UnitValidator(v); err != nil {
|
|
return &ValidationError{Name: "unit", err: fmt.Errorf(`ent: validator failed for field "CallPool.unit": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.SnMode(); !ok {
|
|
return &ValidationError{Name: "snMode", err: errors.New(`ent: missing required field "CallPool.snMode"`)}
|
|
}
|
|
if _, ok := _c.mutation.ReqQty(); !ok {
|
|
return &ValidationError{Name: "reqQty", err: errors.New(`ent: missing required field "CallPool.reqQty"`)}
|
|
}
|
|
if _, ok := _c.mutation.AdjQty(); !ok {
|
|
return &ValidationError{Name: "adjQty", err: errors.New(`ent: missing required field "CallPool.adjQty"`)}
|
|
}
|
|
if _, ok := _c.mutation.SentQty(); !ok {
|
|
return &ValidationError{Name: "sentQty", err: errors.New(`ent: missing required field "CallPool.sentQty"`)}
|
|
}
|
|
if _, ok := _c.mutation.ReservedQty(); !ok {
|
|
return &ValidationError{Name: "reservedQty", err: errors.New(`ent: missing required field "CallPool.reservedQty"`)}
|
|
}
|
|
if _, ok := _c.mutation.CrossDay(); !ok {
|
|
return &ValidationError{Name: "crossDay", err: errors.New(`ent: missing required field "CallPool.crossDay"`)}
|
|
}
|
|
if _, ok := _c.mutation.PlanDates(); !ok {
|
|
return &ValidationError{Name: "planDates", err: errors.New(`ent: missing required field "CallPool.planDates"`)}
|
|
}
|
|
if v, ok := _c.mutation.PlanDates(); ok {
|
|
if err := callpool.PlanDatesValidator(v); err != nil {
|
|
return &ValidationError{Name: "planDates", err: fmt.Errorf(`ent: validator failed for field "CallPool.planDates": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "CallPool.createdAt"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updatedAt", err: errors.New(`ent: missing required field "CallPool.updatedAt"`)}
|
|
}
|
|
if v, ok := _c.mutation.ID(); ok {
|
|
if err := callpool.IDValidator(v); err != nil {
|
|
return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "CallPool.id": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *CallPoolCreate) sqlSave(ctx context.Context) (*CallPool, 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 *CallPoolCreate) createSpec() (*CallPool, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &CallPool{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(callpool.Table, sqlgraph.NewFieldSpec(callpool.FieldID, field.TypeInt))
|
|
)
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = id
|
|
}
|
|
if value, ok := _c.mutation.StationNo(); ok {
|
|
_spec.SetField(callpool.FieldStationNo, field.TypeInt, value)
|
|
_node.StationNo = value
|
|
}
|
|
if value, ok := _c.mutation.MaterialCode(); ok {
|
|
_spec.SetField(callpool.FieldMaterialCode, field.TypeString, value)
|
|
_node.MaterialCode = value
|
|
}
|
|
if value, ok := _c.mutation.MaterialName(); ok {
|
|
_spec.SetField(callpool.FieldMaterialName, field.TypeString, value)
|
|
_node.MaterialName = value
|
|
}
|
|
if value, ok := _c.mutation.Unit(); ok {
|
|
_spec.SetField(callpool.FieldUnit, field.TypeString, value)
|
|
_node.Unit = value
|
|
}
|
|
if value, ok := _c.mutation.SnMode(); ok {
|
|
_spec.SetField(callpool.FieldSnMode, field.TypeInt, value)
|
|
_node.SnMode = value
|
|
}
|
|
if value, ok := _c.mutation.ReqQty(); ok {
|
|
_spec.SetField(callpool.FieldReqQty, field.TypeInt, value)
|
|
_node.ReqQty = value
|
|
}
|
|
if value, ok := _c.mutation.AdjQty(); ok {
|
|
_spec.SetField(callpool.FieldAdjQty, field.TypeInt, value)
|
|
_node.AdjQty = value
|
|
}
|
|
if value, ok := _c.mutation.SentQty(); ok {
|
|
_spec.SetField(callpool.FieldSentQty, field.TypeInt, value)
|
|
_node.SentQty = value
|
|
}
|
|
if value, ok := _c.mutation.ReservedQty(); ok {
|
|
_spec.SetField(callpool.FieldReservedQty, field.TypeInt, value)
|
|
_node.ReservedQty = value
|
|
}
|
|
if value, ok := _c.mutation.CrossDay(); ok {
|
|
_spec.SetField(callpool.FieldCrossDay, field.TypeBool, value)
|
|
_node.CrossDay = value
|
|
}
|
|
if value, ok := _c.mutation.PlanDates(); ok {
|
|
_spec.SetField(callpool.FieldPlanDates, field.TypeString, value)
|
|
_node.PlanDates = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(callpool.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(callpool.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// CallPoolCreateBulk is the builder for creating many CallPool entities in bulk.
|
|
type CallPoolCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*CallPoolCreate
|
|
}
|
|
|
|
// Save creates the CallPool entities in the database.
|
|
func (_c *CallPoolCreateBulk) Save(ctx context.Context) ([]*CallPool, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*CallPool, 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.(*CallPoolMutation)
|
|
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 *CallPoolCreateBulk) SaveX(ctx context.Context) []*CallPool {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *CallPoolCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *CallPoolCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|