diff --git a/bj_power_mes/bj_power_mes.go b/bj_power_mes/bj_power_mes.go index e720245..66ef696 100644 --- a/bj_power_mes/bj_power_mes.go +++ b/bj_power_mes/bj_power_mes.go @@ -820,21 +820,7 @@ func runServe(c config.Config, asService bool) { } }() - // 退料 AGV 自动派车扫描(2026-11-04 口径定稿):每 10 秒一轮,拉取 WMS「PENDING+运输方式=AGV+未派车」 - // 退料单,传感器检测到退料接驳台有托盘且 JBT21 有空位才自动派车(JBT21 无空位等待,库管不点派车)。 - // PLC 托盘传感器为被动读取,物理上必须轮询才能"检测到";每轮仅查未派退料单,开销极小。 - go func() { - time.Sleep(15 * time.Second) - ticker := time.NewTicker(10 * time.Second) - defer ticker.Stop() - for range ticker.C { - bctx := context.Background() - if _, err := logic.New(ctx).AutoDispatchReturnAGV(bctx); err != nil { - gologx.Errorf("退料 AGV 自动派车扫描失败(WMS 不可达属正常): %v", err) - } - } - }() - + // 2026-11-28 拍板:退料 AGV 10 秒轮询扫描整条删除——退料提交时当场校验并派车,不再后台猜时机。 fmt.Printf("Starting bj_power_mes server at %s:%d...\n", c.Host, c.Port) gologx.Infof("Starting bj_power_mes server at %s:%d...", c.Host, c.Port) diff --git a/bj_power_mes/ent/client.go b/bj_power_mes/ent/client.go index 10db8b9..e39ae3a 100644 --- a/bj_power_mes/ent/client.go +++ b/bj_power_mes/ent/client.go @@ -43,6 +43,8 @@ import ( "bj_power_mes/ent/station" "bj_power_mes/ent/stationshift" "bj_power_mes/ent/stationstate" + "bj_power_mes/ent/stationterminalevent" + "bj_power_mes/ent/stationterminalstate" "bj_power_mes/ent/stepcriterion" "bj_power_mes/ent/stepdata" "bj_power_mes/ent/stepsignrecord" @@ -132,6 +134,10 @@ type Client struct { StationShift *StationShiftClient // StationState is the client for interacting with the StationState builders. StationState *StationStateClient + // StationTerminalEvent is the client for interacting with the StationTerminalEvent builders. + StationTerminalEvent *StationTerminalEventClient + // StationTerminalState is the client for interacting with the StationTerminalState builders. + StationTerminalState *StationTerminalStateClient // StepCriterion is the client for interacting with the StepCriterion builders. StepCriterion *StepCriterionClient // StepData is the client for interacting with the StepData builders. @@ -203,6 +209,8 @@ func (c *Client) init() { c.Station = NewStationClient(c.config) c.StationShift = NewStationShiftClient(c.config) c.StationState = NewStationStateClient(c.config) + c.StationTerminalEvent = NewStationTerminalEventClient(c.config) + c.StationTerminalState = NewStationTerminalStateClient(c.config) c.StepCriterion = NewStepCriterionClient(c.config) c.StepData = NewStepDataClient(c.config) c.StepSignRecord = NewStepSignRecordClient(c.config) @@ -341,6 +349,8 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Station: NewStationClient(cfg), StationShift: NewStationShiftClient(cfg), StationState: NewStationStateClient(cfg), + StationTerminalEvent: NewStationTerminalEventClient(cfg), + StationTerminalState: NewStationTerminalStateClient(cfg), StepCriterion: NewStepCriterionClient(cfg), StepData: NewStepDataClient(cfg), StepSignRecord: NewStepSignRecordClient(cfg), @@ -406,6 +416,8 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Station: NewStationClient(cfg), StationShift: NewStationShiftClient(cfg), StationState: NewStationStateClient(cfg), + StationTerminalEvent: NewStationTerminalEventClient(cfg), + StationTerminalState: NewStationTerminalStateClient(cfg), StepCriterion: NewStepCriterionClient(cfg), StepData: NewStepDataClient(cfg), StepSignRecord: NewStepSignRecordClient(cfg), @@ -455,10 +467,11 @@ func (c *Client) Use(hooks ...Hook) { c.MaterialQtyReport, c.MaterialRequest, c.Permission, c.PlcSendLog, c.ProcessFlow, c.ProcessStep, c.ProductBOM, c.ProductProcess, c.ProductProcessItem, c.ProductProcessMaterial, c.Role, c.SemiFlow, - c.ShortageRequest, c.Station, c.StationShift, c.StationState, c.StepCriterion, - c.StepData, c.StepSignRecord, c.SyncFailure, c.SysConfig, c.TorqueRecord, - c.TrialRecord, c.User, c.UserStation, c.WorkOrder, c.Workpiece, - c.WorkpieceBind, c.WorkpieceLifecycleLog, c.WorkpieceProcess, + c.ShortageRequest, c.Station, c.StationShift, c.StationState, + c.StationTerminalEvent, c.StationTerminalState, c.StepCriterion, c.StepData, + c.StepSignRecord, c.SyncFailure, c.SysConfig, c.TorqueRecord, c.TrialRecord, + c.User, c.UserStation, c.WorkOrder, c.Workpiece, c.WorkpieceBind, + c.WorkpieceLifecycleLog, c.WorkpieceProcess, } { n.Use(hooks...) } @@ -474,10 +487,11 @@ func (c *Client) Intercept(interceptors ...Interceptor) { c.MaterialQtyReport, c.MaterialRequest, c.Permission, c.PlcSendLog, c.ProcessFlow, c.ProcessStep, c.ProductBOM, c.ProductProcess, c.ProductProcessItem, c.ProductProcessMaterial, c.Role, c.SemiFlow, - c.ShortageRequest, c.Station, c.StationShift, c.StationState, c.StepCriterion, - c.StepData, c.StepSignRecord, c.SyncFailure, c.SysConfig, c.TorqueRecord, - c.TrialRecord, c.User, c.UserStation, c.WorkOrder, c.Workpiece, - c.WorkpieceBind, c.WorkpieceLifecycleLog, c.WorkpieceProcess, + c.ShortageRequest, c.Station, c.StationShift, c.StationState, + c.StationTerminalEvent, c.StationTerminalState, c.StepCriterion, c.StepData, + c.StepSignRecord, c.SyncFailure, c.SysConfig, c.TorqueRecord, c.TrialRecord, + c.User, c.UserStation, c.WorkOrder, c.Workpiece, c.WorkpieceBind, + c.WorkpieceLifecycleLog, c.WorkpieceProcess, } { n.Intercept(interceptors...) } @@ -550,6 +564,10 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.StationShift.mutate(ctx, m) case *StationStateMutation: return c.StationState.mutate(ctx, m) + case *StationTerminalEventMutation: + return c.StationTerminalEvent.mutate(ctx, m) + case *StationTerminalStateMutation: + return c.StationTerminalState.mutate(ctx, m) case *StepCriterionMutation: return c.StepCriterion.mutate(ctx, m) case *StepDataMutation: @@ -4839,6 +4857,272 @@ func (c *StationStateClient) mutate(ctx context.Context, m *StationStateMutation } } +// StationTerminalEventClient is a client for the StationTerminalEvent schema. +type StationTerminalEventClient struct { + config +} + +// NewStationTerminalEventClient returns a client for the StationTerminalEvent from the given config. +func NewStationTerminalEventClient(c config) *StationTerminalEventClient { + return &StationTerminalEventClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `stationterminalevent.Hooks(f(g(h())))`. +func (c *StationTerminalEventClient) Use(hooks ...Hook) { + c.hooks.StationTerminalEvent = append(c.hooks.StationTerminalEvent, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `stationterminalevent.Intercept(f(g(h())))`. +func (c *StationTerminalEventClient) Intercept(interceptors ...Interceptor) { + c.inters.StationTerminalEvent = append(c.inters.StationTerminalEvent, interceptors...) +} + +// Create returns a builder for creating a StationTerminalEvent entity. +func (c *StationTerminalEventClient) Create() *StationTerminalEventCreate { + mutation := newStationTerminalEventMutation(c.config, OpCreate) + return &StationTerminalEventCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of StationTerminalEvent entities. +func (c *StationTerminalEventClient) CreateBulk(builders ...*StationTerminalEventCreate) *StationTerminalEventCreateBulk { + return &StationTerminalEventCreateBulk{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 *StationTerminalEventClient) MapCreateBulk(slice any, setFunc func(*StationTerminalEventCreate, int)) *StationTerminalEventCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &StationTerminalEventCreateBulk{err: fmt.Errorf("calling to StationTerminalEventClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*StationTerminalEventCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &StationTerminalEventCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for StationTerminalEvent. +func (c *StationTerminalEventClient) Update() *StationTerminalEventUpdate { + mutation := newStationTerminalEventMutation(c.config, OpUpdate) + return &StationTerminalEventUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *StationTerminalEventClient) UpdateOne(_m *StationTerminalEvent) *StationTerminalEventUpdateOne { + mutation := newStationTerminalEventMutation(c.config, OpUpdateOne, withStationTerminalEvent(_m)) + return &StationTerminalEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *StationTerminalEventClient) UpdateOneID(id int) *StationTerminalEventUpdateOne { + mutation := newStationTerminalEventMutation(c.config, OpUpdateOne, withStationTerminalEventID(id)) + return &StationTerminalEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for StationTerminalEvent. +func (c *StationTerminalEventClient) Delete() *StationTerminalEventDelete { + mutation := newStationTerminalEventMutation(c.config, OpDelete) + return &StationTerminalEventDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *StationTerminalEventClient) DeleteOne(_m *StationTerminalEvent) *StationTerminalEventDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *StationTerminalEventClient) DeleteOneID(id int) *StationTerminalEventDeleteOne { + builder := c.Delete().Where(stationterminalevent.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &StationTerminalEventDeleteOne{builder} +} + +// Query returns a query builder for StationTerminalEvent. +func (c *StationTerminalEventClient) Query() *StationTerminalEventQuery { + return &StationTerminalEventQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeStationTerminalEvent}, + inters: c.Interceptors(), + } +} + +// Get returns a StationTerminalEvent entity by its id. +func (c *StationTerminalEventClient) Get(ctx context.Context, id int) (*StationTerminalEvent, error) { + return c.Query().Where(stationterminalevent.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *StationTerminalEventClient) GetX(ctx context.Context, id int) *StationTerminalEvent { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *StationTerminalEventClient) Hooks() []Hook { + return c.hooks.StationTerminalEvent +} + +// Interceptors returns the client interceptors. +func (c *StationTerminalEventClient) Interceptors() []Interceptor { + return c.inters.StationTerminalEvent +} + +func (c *StationTerminalEventClient) mutate(ctx context.Context, m *StationTerminalEventMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&StationTerminalEventCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&StationTerminalEventUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&StationTerminalEventUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&StationTerminalEventDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown StationTerminalEvent mutation op: %q", m.Op()) + } +} + +// StationTerminalStateClient is a client for the StationTerminalState schema. +type StationTerminalStateClient struct { + config +} + +// NewStationTerminalStateClient returns a client for the StationTerminalState from the given config. +func NewStationTerminalStateClient(c config) *StationTerminalStateClient { + return &StationTerminalStateClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `stationterminalstate.Hooks(f(g(h())))`. +func (c *StationTerminalStateClient) Use(hooks ...Hook) { + c.hooks.StationTerminalState = append(c.hooks.StationTerminalState, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `stationterminalstate.Intercept(f(g(h())))`. +func (c *StationTerminalStateClient) Intercept(interceptors ...Interceptor) { + c.inters.StationTerminalState = append(c.inters.StationTerminalState, interceptors...) +} + +// Create returns a builder for creating a StationTerminalState entity. +func (c *StationTerminalStateClient) Create() *StationTerminalStateCreate { + mutation := newStationTerminalStateMutation(c.config, OpCreate) + return &StationTerminalStateCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of StationTerminalState entities. +func (c *StationTerminalStateClient) CreateBulk(builders ...*StationTerminalStateCreate) *StationTerminalStateCreateBulk { + return &StationTerminalStateCreateBulk{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 *StationTerminalStateClient) MapCreateBulk(slice any, setFunc func(*StationTerminalStateCreate, int)) *StationTerminalStateCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &StationTerminalStateCreateBulk{err: fmt.Errorf("calling to StationTerminalStateClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*StationTerminalStateCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &StationTerminalStateCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for StationTerminalState. +func (c *StationTerminalStateClient) Update() *StationTerminalStateUpdate { + mutation := newStationTerminalStateMutation(c.config, OpUpdate) + return &StationTerminalStateUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *StationTerminalStateClient) UpdateOne(_m *StationTerminalState) *StationTerminalStateUpdateOne { + mutation := newStationTerminalStateMutation(c.config, OpUpdateOne, withStationTerminalState(_m)) + return &StationTerminalStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *StationTerminalStateClient) UpdateOneID(id int) *StationTerminalStateUpdateOne { + mutation := newStationTerminalStateMutation(c.config, OpUpdateOne, withStationTerminalStateID(id)) + return &StationTerminalStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for StationTerminalState. +func (c *StationTerminalStateClient) Delete() *StationTerminalStateDelete { + mutation := newStationTerminalStateMutation(c.config, OpDelete) + return &StationTerminalStateDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *StationTerminalStateClient) DeleteOne(_m *StationTerminalState) *StationTerminalStateDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *StationTerminalStateClient) DeleteOneID(id int) *StationTerminalStateDeleteOne { + builder := c.Delete().Where(stationterminalstate.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &StationTerminalStateDeleteOne{builder} +} + +// Query returns a query builder for StationTerminalState. +func (c *StationTerminalStateClient) Query() *StationTerminalStateQuery { + return &StationTerminalStateQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeStationTerminalState}, + inters: c.Interceptors(), + } +} + +// Get returns a StationTerminalState entity by its id. +func (c *StationTerminalStateClient) Get(ctx context.Context, id int) (*StationTerminalState, error) { + return c.Query().Where(stationterminalstate.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *StationTerminalStateClient) GetX(ctx context.Context, id int) *StationTerminalState { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *StationTerminalStateClient) Hooks() []Hook { + return c.hooks.StationTerminalState +} + +// Interceptors returns the client interceptors. +func (c *StationTerminalStateClient) Interceptors() []Interceptor { + return c.inters.StationTerminalState +} + +func (c *StationTerminalStateClient) mutate(ctx context.Context, m *StationTerminalStateMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&StationTerminalStateCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&StationTerminalStateUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&StationTerminalStateUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&StationTerminalStateDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown StationTerminalState mutation op: %q", m.Op()) + } +} + // StepCriterionClient is a client for the StepCriterion schema. type StepCriterionClient struct { config @@ -6709,10 +6993,10 @@ type ( InspectionRecord, LinePoint, LossLedger, Material, MaterialQtyReport, MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, ProductBOM, ProductProcess, ProductProcessItem, ProductProcessMaterial, Role, SemiFlow, - ShortageRequest, Station, StationShift, StationState, StepCriterion, StepData, - StepSignRecord, SyncFailure, SysConfig, TorqueRecord, TrialRecord, User, - UserStation, WorkOrder, Workpiece, WorkpieceBind, WorkpieceLifecycleLog, - WorkpieceProcess []ent.Hook + ShortageRequest, Station, StationShift, StationState, StationTerminalEvent, + StationTerminalState, StepCriterion, StepData, StepSignRecord, SyncFailure, + SysConfig, TorqueRecord, TrialRecord, User, UserStation, WorkOrder, Workpiece, + WorkpieceBind, WorkpieceLifecycleLog, WorkpieceProcess []ent.Hook } inters struct { AgvPoint, AgvTask, AgvVehicleState, Alert, AlertRule, AssociationTrace, @@ -6720,9 +7004,9 @@ type ( InspectionRecord, LinePoint, LossLedger, Material, MaterialQtyReport, MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, ProductBOM, ProductProcess, ProductProcessItem, ProductProcessMaterial, Role, SemiFlow, - ShortageRequest, Station, StationShift, StationState, StepCriterion, StepData, - StepSignRecord, SyncFailure, SysConfig, TorqueRecord, TrialRecord, User, - UserStation, WorkOrder, Workpiece, WorkpieceBind, WorkpieceLifecycleLog, - WorkpieceProcess []ent.Interceptor + ShortageRequest, Station, StationShift, StationState, StationTerminalEvent, + StationTerminalState, StepCriterion, StepData, StepSignRecord, SyncFailure, + SysConfig, TorqueRecord, TrialRecord, User, UserStation, WorkOrder, Workpiece, + WorkpieceBind, WorkpieceLifecycleLog, WorkpieceProcess []ent.Interceptor } ) diff --git a/bj_power_mes/ent/dailyplan.go b/bj_power_mes/ent/dailyplan.go index acdb3e1..0abc9ca 100644 --- a/bj_power_mes/ent/dailyplan.go +++ b/bj_power_mes/ent/dailyplan.go @@ -30,6 +30,8 @@ type DailyPlan struct { StationPlanQty map[string]int `json:"stationPlanQty,omitempty"` // Status holds the value of the "status" field. Status string `json:"status,omitempty"` + // 废弃标记:停用后置true,待启用的PENDING为false + Discarded bool `json:"discarded,omitempty"` // Operator holds the value of the "operator" field. Operator string `json:"operator,omitempty"` // CreatedAt holds the value of the "createdAt" field. @@ -46,6 +48,8 @@ func (*DailyPlan) scanValues(columns []string) ([]any, error) { switch columns[i] { case dailyplan.FieldStationPlanQty: values[i] = new([]byte) + case dailyplan.FieldDiscarded: + values[i] = new(sql.NullBool) case dailyplan.FieldID, dailyplan.FieldPlanQty, dailyplan.FieldCompletedQty: values[i] = new(sql.NullInt64) case dailyplan.FieldOrderNo, dailyplan.FieldPlanDate, dailyplan.FieldStatus, dailyplan.FieldOperator: @@ -111,6 +115,12 @@ func (_m *DailyPlan) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Status = value.String } + case dailyplan.FieldDiscarded: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field discarded", values[i]) + } else if value.Valid { + _m.Discarded = value.Bool + } case dailyplan.FieldOperator: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field operator", values[i]) @@ -184,6 +194,9 @@ func (_m *DailyPlan) String() string { builder.WriteString("status=") builder.WriteString(_m.Status) builder.WriteString(", ") + builder.WriteString("discarded=") + builder.WriteString(fmt.Sprintf("%v", _m.Discarded)) + builder.WriteString(", ") builder.WriteString("operator=") builder.WriteString(_m.Operator) builder.WriteString(", ") diff --git a/bj_power_mes/ent/dailyplan/dailyplan.go b/bj_power_mes/ent/dailyplan/dailyplan.go index 1559f70..a0a490b 100644 --- a/bj_power_mes/ent/dailyplan/dailyplan.go +++ b/bj_power_mes/ent/dailyplan/dailyplan.go @@ -25,6 +25,8 @@ const ( FieldStationPlanQty = "station_plan_qty" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" + // FieldDiscarded holds the string denoting the discarded field in the database. + FieldDiscarded = "discarded" // FieldOperator holds the string denoting the operator field in the database. FieldOperator = "operator" // FieldCreatedAt holds the string denoting the createdat field in the database. @@ -44,6 +46,7 @@ var Columns = []string{ FieldCompletedQty, FieldStationPlanQty, FieldStatus, + FieldDiscarded, FieldOperator, FieldCreatedAt, FieldUpdatedAt, @@ -72,6 +75,8 @@ var ( DefaultStatus string // StatusValidator is a validator for the "status" field. It is called by the builders before save. StatusValidator func(string) error + // DefaultDiscarded holds the default value on creation for the "discarded" field. + DefaultDiscarded bool // 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. @@ -119,6 +124,11 @@ func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } +// ByDiscarded orders the results by the discarded field. +func ByDiscarded(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDiscarded, opts...).ToFunc() +} + // ByOperator orders the results by the operator field. func ByOperator(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldOperator, opts...).ToFunc() diff --git a/bj_power_mes/ent/dailyplan/where.go b/bj_power_mes/ent/dailyplan/where.go index 10964c2..eb20cb1 100644 --- a/bj_power_mes/ent/dailyplan/where.go +++ b/bj_power_mes/ent/dailyplan/where.go @@ -79,6 +79,11 @@ func Status(v string) predicate.DailyPlan { return predicate.DailyPlan(sql.FieldEQ(FieldStatus, v)) } +// Discarded applies equality check predicate on the "discarded" field. It's identical to DiscardedEQ. +func Discarded(v bool) predicate.DailyPlan { + return predicate.DailyPlan(sql.FieldEQ(FieldDiscarded, v)) +} + // Operator applies equality check predicate on the "operator" field. It's identical to OperatorEQ. func Operator(v string) predicate.DailyPlan { return predicate.DailyPlan(sql.FieldEQ(FieldOperator, v)) @@ -379,6 +384,16 @@ func StatusContainsFold(v string) predicate.DailyPlan { return predicate.DailyPlan(sql.FieldContainsFold(FieldStatus, v)) } +// DiscardedEQ applies the EQ predicate on the "discarded" field. +func DiscardedEQ(v bool) predicate.DailyPlan { + return predicate.DailyPlan(sql.FieldEQ(FieldDiscarded, v)) +} + +// DiscardedNEQ applies the NEQ predicate on the "discarded" field. +func DiscardedNEQ(v bool) predicate.DailyPlan { + return predicate.DailyPlan(sql.FieldNEQ(FieldDiscarded, v)) +} + // OperatorEQ applies the EQ predicate on the "operator" field. func OperatorEQ(v string) predicate.DailyPlan { return predicate.DailyPlan(sql.FieldEQ(FieldOperator, v)) diff --git a/bj_power_mes/ent/dailyplan_create.go b/bj_power_mes/ent/dailyplan_create.go index b75b4d5..a8767e8 100644 --- a/bj_power_mes/ent/dailyplan_create.go +++ b/bj_power_mes/ent/dailyplan_create.go @@ -80,6 +80,20 @@ func (_c *DailyPlanCreate) SetNillableStatus(v *string) *DailyPlanCreate { return _c } +// SetDiscarded sets the "discarded" field. +func (_c *DailyPlanCreate) SetDiscarded(v bool) *DailyPlanCreate { + _c.mutation.SetDiscarded(v) + return _c +} + +// SetNillableDiscarded sets the "discarded" field if the given value is not nil. +func (_c *DailyPlanCreate) SetNillableDiscarded(v *bool) *DailyPlanCreate { + if v != nil { + _c.SetDiscarded(*v) + } + return _c +} + // SetOperator sets the "operator" field. func (_c *DailyPlanCreate) SetOperator(v string) *DailyPlanCreate { _c.mutation.SetOperator(v) @@ -175,6 +189,10 @@ func (_c *DailyPlanCreate) defaults() { v := dailyplan.DefaultStatus _c.mutation.SetStatus(v) } + if _, ok := _c.mutation.Discarded(); !ok { + v := dailyplan.DefaultDiscarded + _c.mutation.SetDiscarded(v) + } if _, ok := _c.mutation.Operator(); !ok { v := dailyplan.DefaultOperator _c.mutation.SetOperator(v) @@ -221,6 +239,9 @@ func (_c *DailyPlanCreate) check() error { return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "DailyPlan.status": %w`, err)} } } + if _, ok := _c.mutation.Discarded(); !ok { + return &ValidationError{Name: "discarded", err: errors.New(`ent: missing required field "DailyPlan.discarded"`)} + } if _, ok := _c.mutation.Operator(); !ok { return &ValidationError{Name: "operator", err: errors.New(`ent: missing required field "DailyPlan.operator"`)} } @@ -293,6 +314,10 @@ func (_c *DailyPlanCreate) createSpec() (*DailyPlan, *sqlgraph.CreateSpec) { _spec.SetField(dailyplan.FieldStatus, field.TypeString, value) _node.Status = value } + if value, ok := _c.mutation.Discarded(); ok { + _spec.SetField(dailyplan.FieldDiscarded, field.TypeBool, value) + _node.Discarded = value + } if value, ok := _c.mutation.Operator(); ok { _spec.SetField(dailyplan.FieldOperator, field.TypeString, value) _node.Operator = value diff --git a/bj_power_mes/ent/dailyplan_update.go b/bj_power_mes/ent/dailyplan_update.go index d899043..f50da6e 100644 --- a/bj_power_mes/ent/dailyplan_update.go +++ b/bj_power_mes/ent/dailyplan_update.go @@ -125,6 +125,20 @@ func (_u *DailyPlanUpdate) SetNillableStatus(v *string) *DailyPlanUpdate { return _u } +// SetDiscarded sets the "discarded" field. +func (_u *DailyPlanUpdate) SetDiscarded(v bool) *DailyPlanUpdate { + _u.mutation.SetDiscarded(v) + return _u +} + +// SetNillableDiscarded sets the "discarded" field if the given value is not nil. +func (_u *DailyPlanUpdate) SetNillableDiscarded(v *bool) *DailyPlanUpdate { + if v != nil { + _u.SetDiscarded(*v) + } + return _u +} + // SetOperator sets the "operator" field. func (_u *DailyPlanUpdate) SetOperator(v string) *DailyPlanUpdate { _u.mutation.SetOperator(v) @@ -262,6 +276,9 @@ func (_u *DailyPlanUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Status(); ok { _spec.SetField(dailyplan.FieldStatus, field.TypeString, value) } + if value, ok := _u.mutation.Discarded(); ok { + _spec.SetField(dailyplan.FieldDiscarded, field.TypeBool, value) + } if value, ok := _u.mutation.Operator(); ok { _spec.SetField(dailyplan.FieldOperator, field.TypeString, value) } @@ -389,6 +406,20 @@ func (_u *DailyPlanUpdateOne) SetNillableStatus(v *string) *DailyPlanUpdateOne { return _u } +// SetDiscarded sets the "discarded" field. +func (_u *DailyPlanUpdateOne) SetDiscarded(v bool) *DailyPlanUpdateOne { + _u.mutation.SetDiscarded(v) + return _u +} + +// SetNillableDiscarded sets the "discarded" field if the given value is not nil. +func (_u *DailyPlanUpdateOne) SetNillableDiscarded(v *bool) *DailyPlanUpdateOne { + if v != nil { + _u.SetDiscarded(*v) + } + return _u +} + // SetOperator sets the "operator" field. func (_u *DailyPlanUpdateOne) SetOperator(v string) *DailyPlanUpdateOne { _u.mutation.SetOperator(v) @@ -556,6 +587,9 @@ func (_u *DailyPlanUpdateOne) sqlSave(ctx context.Context) (_node *DailyPlan, er if value, ok := _u.mutation.Status(); ok { _spec.SetField(dailyplan.FieldStatus, field.TypeString, value) } + if value, ok := _u.mutation.Discarded(); ok { + _spec.SetField(dailyplan.FieldDiscarded, field.TypeBool, value) + } if value, ok := _u.mutation.Operator(); ok { _spec.SetField(dailyplan.FieldOperator, field.TypeString, value) } diff --git a/bj_power_mes/ent/ent.go b/bj_power_mes/ent/ent.go index 9272375..d76e000 100644 --- a/bj_power_mes/ent/ent.go +++ b/bj_power_mes/ent/ent.go @@ -35,6 +35,8 @@ import ( "bj_power_mes/ent/station" "bj_power_mes/ent/stationshift" "bj_power_mes/ent/stationstate" + "bj_power_mes/ent/stationterminalevent" + "bj_power_mes/ent/stationterminalstate" "bj_power_mes/ent/stepcriterion" "bj_power_mes/ent/stepdata" "bj_power_mes/ent/stepsignrecord" @@ -150,6 +152,8 @@ func checkColumn(t, c string) error { station.Table: station.ValidColumn, stationshift.Table: stationshift.ValidColumn, stationstate.Table: stationstate.ValidColumn, + stationterminalevent.Table: stationterminalevent.ValidColumn, + stationterminalstate.Table: stationterminalstate.ValidColumn, stepcriterion.Table: stepcriterion.ValidColumn, stepdata.Table: stepdata.ValidColumn, stepsignrecord.Table: stepsignrecord.ValidColumn, diff --git a/bj_power_mes/ent/hook/hook.go b/bj_power_mes/ent/hook/hook.go index dcb1417..ddb2087 100644 --- a/bj_power_mes/ent/hook/hook.go +++ b/bj_power_mes/ent/hook/hook.go @@ -392,6 +392,30 @@ func (f StationStateFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.StationStateMutation", m) } +// The StationTerminalEventFunc type is an adapter to allow the use of ordinary +// function as StationTerminalEvent mutator. +type StationTerminalEventFunc func(context.Context, *ent.StationTerminalEventMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f StationTerminalEventFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.StationTerminalEventMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.StationTerminalEventMutation", m) +} + +// The StationTerminalStateFunc type is an adapter to allow the use of ordinary +// function as StationTerminalState mutator. +type StationTerminalStateFunc func(context.Context, *ent.StationTerminalStateMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f StationTerminalStateFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.StationTerminalStateMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.StationTerminalStateMutation", m) +} + // The StepCriterionFunc type is an adapter to allow the use of ordinary // function as StepCriterion mutator. type StepCriterionFunc func(context.Context, *ent.StepCriterionMutation) (ent.Value, error) diff --git a/bj_power_mes/ent/lossledger.go b/bj_power_mes/ent/lossledger.go index ffa0c85..906ecc2 100644 --- a/bj_power_mes/ent/lossledger.go +++ b/bj_power_mes/ent/lossledger.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" ) -// LossLedger 损耗台账:退料差额自动落账,主管批注(后审核)。 +// LossLedger 损耗台账:退料差额自动落账,只读(2026-11-27 取消批注)。 type LossLedger struct { config `json:"-"` // ID of the ent. @@ -35,14 +35,6 @@ type LossLedger struct { ReturnNo string `json:"returnNo,omitempty"` // 关联工单号(可空) WorkOrderNo string `json:"workOrderNo,omitempty"` - // PENDING待批注/COMMENTED已批注 - Status string `json:"status,omitempty"` - // 主管批注回复 - Comment string `json:"comment,omitempty"` - // 批注人 - Commenter string `json:"commenter,omitempty"` - // 批注时间 unix秒 - CommentedAt int64 `json:"commentedAt,omitempty"` // 退料操作人 Operator string `json:"operator,omitempty"` // CreatedAt holds the value of the "createdAt" field. @@ -57,9 +49,9 @@ func (*LossLedger) scanValues(columns []string) ([]any, error) { switch columns[i] { case lossledger.FieldTheoryQty, lossledger.FieldActualQty, lossledger.FieldLossQty: values[i] = new(sql.NullFloat64) - case lossledger.FieldID, lossledger.FieldStationNo, lossledger.FieldCommentedAt: + case lossledger.FieldID, lossledger.FieldStationNo: values[i] = new(sql.NullInt64) - case lossledger.FieldMaterialCode, lossledger.FieldMaterialName, lossledger.FieldReason, lossledger.FieldReturnNo, lossledger.FieldWorkOrderNo, lossledger.FieldStatus, lossledger.FieldComment, lossledger.FieldCommenter, lossledger.FieldOperator: + case lossledger.FieldMaterialCode, lossledger.FieldMaterialName, lossledger.FieldReason, lossledger.FieldReturnNo, lossledger.FieldWorkOrderNo, lossledger.FieldOperator: values[i] = new(sql.NullString) case lossledger.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -138,30 +130,6 @@ func (_m *LossLedger) assignValues(columns []string, values []any) error { } else if value.Valid { _m.WorkOrderNo = value.String } - case lossledger.FieldStatus: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field status", values[i]) - } else if value.Valid { - _m.Status = value.String - } - case lossledger.FieldComment: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field comment", values[i]) - } else if value.Valid { - _m.Comment = value.String - } - case lossledger.FieldCommenter: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field commenter", values[i]) - } else if value.Valid { - _m.Commenter = value.String - } - case lossledger.FieldCommentedAt: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field commentedAt", values[i]) - } else if value.Valid { - _m.CommentedAt = value.Int64 - } case lossledger.FieldOperator: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field operator", values[i]) @@ -237,18 +205,6 @@ func (_m *LossLedger) String() string { builder.WriteString("workOrderNo=") builder.WriteString(_m.WorkOrderNo) builder.WriteString(", ") - builder.WriteString("status=") - builder.WriteString(_m.Status) - builder.WriteString(", ") - builder.WriteString("comment=") - builder.WriteString(_m.Comment) - builder.WriteString(", ") - builder.WriteString("commenter=") - builder.WriteString(_m.Commenter) - builder.WriteString(", ") - builder.WriteString("commentedAt=") - builder.WriteString(fmt.Sprintf("%v", _m.CommentedAt)) - builder.WriteString(", ") builder.WriteString("operator=") builder.WriteString(_m.Operator) builder.WriteString(", ") diff --git a/bj_power_mes/ent/lossledger/lossledger.go b/bj_power_mes/ent/lossledger/lossledger.go index fbb68e6..6060645 100644 --- a/bj_power_mes/ent/lossledger/lossledger.go +++ b/bj_power_mes/ent/lossledger/lossledger.go @@ -31,14 +31,6 @@ const ( FieldReturnNo = "return_no" // FieldWorkOrderNo holds the string denoting the workorderno field in the database. FieldWorkOrderNo = "work_order_no" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // FieldComment holds the string denoting the comment field in the database. - FieldComment = "comment" - // FieldCommenter holds the string denoting the commenter field in the database. - FieldCommenter = "commenter" - // FieldCommentedAt holds the string denoting the commentedat field in the database. - FieldCommentedAt = "commented_at" // FieldOperator holds the string denoting the operator field in the database. FieldOperator = "operator" // FieldCreatedAt holds the string denoting the createdat field in the database. @@ -59,10 +51,6 @@ var Columns = []string{ FieldReason, FieldReturnNo, FieldWorkOrderNo, - FieldStatus, - FieldComment, - FieldCommenter, - FieldCommentedAt, FieldOperator, FieldCreatedAt, } @@ -94,20 +82,6 @@ var ( DefaultWorkOrderNo string // WorkOrderNoValidator is a validator for the "workOrderNo" field. It is called by the builders before save. WorkOrderNoValidator func(string) error - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus string - // StatusValidator is a validator for the "status" field. It is called by the builders before save. - StatusValidator func(string) error - // DefaultComment holds the default value on creation for the "comment" field. - DefaultComment string - // CommentValidator is a validator for the "comment" field. It is called by the builders before save. - CommentValidator func(string) error - // DefaultCommenter holds the default value on creation for the "commenter" field. - DefaultCommenter string - // CommenterValidator is a validator for the "commenter" field. It is called by the builders before save. - CommenterValidator func(string) error - // DefaultCommentedAt holds the default value on creation for the "commentedAt" field. - DefaultCommentedAt int64 // 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. @@ -169,26 +143,6 @@ func ByWorkOrderNo(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldWorkOrderNo, opts...).ToFunc() } -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByComment orders the results by the comment field. -func ByComment(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldComment, opts...).ToFunc() -} - -// ByCommenter orders the results by the commenter field. -func ByCommenter(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCommenter, opts...).ToFunc() -} - -// ByCommentedAt orders the results by the commentedAt field. -func ByCommentedAt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCommentedAt, opts...).ToFunc() -} - // ByOperator orders the results by the operator field. func ByOperator(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldOperator, opts...).ToFunc() diff --git a/bj_power_mes/ent/lossledger/where.go b/bj_power_mes/ent/lossledger/where.go index c6a7000..af2fd6d 100644 --- a/bj_power_mes/ent/lossledger/where.go +++ b/bj_power_mes/ent/lossledger/where.go @@ -99,26 +99,6 @@ func WorkOrderNo(v string) predicate.LossLedger { return predicate.LossLedger(sql.FieldEQ(FieldWorkOrderNo, v)) } -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldStatus, v)) -} - -// Comment applies equality check predicate on the "comment" field. It's identical to CommentEQ. -func Comment(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldComment, v)) -} - -// Commenter applies equality check predicate on the "commenter" field. It's identical to CommenterEQ. -func Commenter(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldCommenter, v)) -} - -// CommentedAt applies equality check predicate on the "commentedAt" field. It's identical to CommentedAtEQ. -func CommentedAt(v int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldCommentedAt, v)) -} - // Operator applies equality check predicate on the "operator" field. It's identical to OperatorEQ. func Operator(v string) predicate.LossLedger { return predicate.LossLedger(sql.FieldEQ(FieldOperator, v)) @@ -614,241 +594,6 @@ func WorkOrderNoContainsFold(v string) predicate.LossLedger { return predicate.LossLedger(sql.FieldContainsFold(FieldWorkOrderNo, v)) } -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLTE(FieldStatus, v)) -} - -// StatusContains applies the Contains predicate on the "status" field. -func StatusContains(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldContains(FieldStatus, v)) -} - -// StatusHasPrefix applies the HasPrefix predicate on the "status" field. -func StatusHasPrefix(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldHasPrefix(FieldStatus, v)) -} - -// StatusHasSuffix applies the HasSuffix predicate on the "status" field. -func StatusHasSuffix(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldHasSuffix(FieldStatus, v)) -} - -// StatusEqualFold applies the EqualFold predicate on the "status" field. -func StatusEqualFold(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEqualFold(FieldStatus, v)) -} - -// StatusContainsFold applies the ContainsFold predicate on the "status" field. -func StatusContainsFold(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldContainsFold(FieldStatus, v)) -} - -// CommentEQ applies the EQ predicate on the "comment" field. -func CommentEQ(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldComment, v)) -} - -// CommentNEQ applies the NEQ predicate on the "comment" field. -func CommentNEQ(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNEQ(FieldComment, v)) -} - -// CommentIn applies the In predicate on the "comment" field. -func CommentIn(vs ...string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldIn(FieldComment, vs...)) -} - -// CommentNotIn applies the NotIn predicate on the "comment" field. -func CommentNotIn(vs ...string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNotIn(FieldComment, vs...)) -} - -// CommentGT applies the GT predicate on the "comment" field. -func CommentGT(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGT(FieldComment, v)) -} - -// CommentGTE applies the GTE predicate on the "comment" field. -func CommentGTE(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGTE(FieldComment, v)) -} - -// CommentLT applies the LT predicate on the "comment" field. -func CommentLT(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLT(FieldComment, v)) -} - -// CommentLTE applies the LTE predicate on the "comment" field. -func CommentLTE(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLTE(FieldComment, v)) -} - -// CommentContains applies the Contains predicate on the "comment" field. -func CommentContains(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldContains(FieldComment, v)) -} - -// CommentHasPrefix applies the HasPrefix predicate on the "comment" field. -func CommentHasPrefix(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldHasPrefix(FieldComment, v)) -} - -// CommentHasSuffix applies the HasSuffix predicate on the "comment" field. -func CommentHasSuffix(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldHasSuffix(FieldComment, v)) -} - -// CommentEqualFold applies the EqualFold predicate on the "comment" field. -func CommentEqualFold(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEqualFold(FieldComment, v)) -} - -// CommentContainsFold applies the ContainsFold predicate on the "comment" field. -func CommentContainsFold(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldContainsFold(FieldComment, v)) -} - -// CommenterEQ applies the EQ predicate on the "commenter" field. -func CommenterEQ(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldCommenter, v)) -} - -// CommenterNEQ applies the NEQ predicate on the "commenter" field. -func CommenterNEQ(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNEQ(FieldCommenter, v)) -} - -// CommenterIn applies the In predicate on the "commenter" field. -func CommenterIn(vs ...string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldIn(FieldCommenter, vs...)) -} - -// CommenterNotIn applies the NotIn predicate on the "commenter" field. -func CommenterNotIn(vs ...string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNotIn(FieldCommenter, vs...)) -} - -// CommenterGT applies the GT predicate on the "commenter" field. -func CommenterGT(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGT(FieldCommenter, v)) -} - -// CommenterGTE applies the GTE predicate on the "commenter" field. -func CommenterGTE(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGTE(FieldCommenter, v)) -} - -// CommenterLT applies the LT predicate on the "commenter" field. -func CommenterLT(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLT(FieldCommenter, v)) -} - -// CommenterLTE applies the LTE predicate on the "commenter" field. -func CommenterLTE(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLTE(FieldCommenter, v)) -} - -// CommenterContains applies the Contains predicate on the "commenter" field. -func CommenterContains(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldContains(FieldCommenter, v)) -} - -// CommenterHasPrefix applies the HasPrefix predicate on the "commenter" field. -func CommenterHasPrefix(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldHasPrefix(FieldCommenter, v)) -} - -// CommenterHasSuffix applies the HasSuffix predicate on the "commenter" field. -func CommenterHasSuffix(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldHasSuffix(FieldCommenter, v)) -} - -// CommenterEqualFold applies the EqualFold predicate on the "commenter" field. -func CommenterEqualFold(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEqualFold(FieldCommenter, v)) -} - -// CommenterContainsFold applies the ContainsFold predicate on the "commenter" field. -func CommenterContainsFold(v string) predicate.LossLedger { - return predicate.LossLedger(sql.FieldContainsFold(FieldCommenter, v)) -} - -// CommentedAtEQ applies the EQ predicate on the "commentedAt" field. -func CommentedAtEQ(v int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldEQ(FieldCommentedAt, v)) -} - -// CommentedAtNEQ applies the NEQ predicate on the "commentedAt" field. -func CommentedAtNEQ(v int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNEQ(FieldCommentedAt, v)) -} - -// CommentedAtIn applies the In predicate on the "commentedAt" field. -func CommentedAtIn(vs ...int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldIn(FieldCommentedAt, vs...)) -} - -// CommentedAtNotIn applies the NotIn predicate on the "commentedAt" field. -func CommentedAtNotIn(vs ...int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldNotIn(FieldCommentedAt, vs...)) -} - -// CommentedAtGT applies the GT predicate on the "commentedAt" field. -func CommentedAtGT(v int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGT(FieldCommentedAt, v)) -} - -// CommentedAtGTE applies the GTE predicate on the "commentedAt" field. -func CommentedAtGTE(v int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldGTE(FieldCommentedAt, v)) -} - -// CommentedAtLT applies the LT predicate on the "commentedAt" field. -func CommentedAtLT(v int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLT(FieldCommentedAt, v)) -} - -// CommentedAtLTE applies the LTE predicate on the "commentedAt" field. -func CommentedAtLTE(v int64) predicate.LossLedger { - return predicate.LossLedger(sql.FieldLTE(FieldCommentedAt, v)) -} - // OperatorEQ applies the EQ predicate on the "operator" field. func OperatorEQ(v string) predicate.LossLedger { return predicate.LossLedger(sql.FieldEQ(FieldOperator, v)) diff --git a/bj_power_mes/ent/lossledger_create.go b/bj_power_mes/ent/lossledger_create.go index 80db64f..1a83b4a 100644 --- a/bj_power_mes/ent/lossledger_create.go +++ b/bj_power_mes/ent/lossledger_create.go @@ -98,62 +98,6 @@ func (_c *LossLedgerCreate) SetNillableWorkOrderNo(v *string) *LossLedgerCreate return _c } -// SetStatus sets the "status" field. -func (_c *LossLedgerCreate) SetStatus(v string) *LossLedgerCreate { - _c.mutation.SetStatus(v) - return _c -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *LossLedgerCreate) SetNillableStatus(v *string) *LossLedgerCreate { - if v != nil { - _c.SetStatus(*v) - } - return _c -} - -// SetComment sets the "comment" field. -func (_c *LossLedgerCreate) SetComment(v string) *LossLedgerCreate { - _c.mutation.SetComment(v) - return _c -} - -// SetNillableComment sets the "comment" field if the given value is not nil. -func (_c *LossLedgerCreate) SetNillableComment(v *string) *LossLedgerCreate { - if v != nil { - _c.SetComment(*v) - } - return _c -} - -// SetCommenter sets the "commenter" field. -func (_c *LossLedgerCreate) SetCommenter(v string) *LossLedgerCreate { - _c.mutation.SetCommenter(v) - return _c -} - -// SetNillableCommenter sets the "commenter" field if the given value is not nil. -func (_c *LossLedgerCreate) SetNillableCommenter(v *string) *LossLedgerCreate { - if v != nil { - _c.SetCommenter(*v) - } - return _c -} - -// SetCommentedAt sets the "commentedAt" field. -func (_c *LossLedgerCreate) SetCommentedAt(v int64) *LossLedgerCreate { - _c.mutation.SetCommentedAt(v) - return _c -} - -// SetNillableCommentedAt sets the "commentedAt" field if the given value is not nil. -func (_c *LossLedgerCreate) SetNillableCommentedAt(v *int64) *LossLedgerCreate { - if v != nil { - _c.SetCommentedAt(*v) - } - return _c -} - // SetOperator sets the "operator" field. func (_c *LossLedgerCreate) SetOperator(v string) *LossLedgerCreate { _c.mutation.SetOperator(v) @@ -229,22 +173,6 @@ func (_c *LossLedgerCreate) defaults() { v := lossledger.DefaultWorkOrderNo _c.mutation.SetWorkOrderNo(v) } - if _, ok := _c.mutation.Status(); !ok { - v := lossledger.DefaultStatus - _c.mutation.SetStatus(v) - } - if _, ok := _c.mutation.Comment(); !ok { - v := lossledger.DefaultComment - _c.mutation.SetComment(v) - } - if _, ok := _c.mutation.Commenter(); !ok { - v := lossledger.DefaultCommenter - _c.mutation.SetCommenter(v) - } - if _, ok := _c.mutation.CommentedAt(); !ok { - v := lossledger.DefaultCommentedAt - _c.mutation.SetCommentedAt(v) - } if _, ok := _c.mutation.Operator(); !ok { v := lossledger.DefaultOperator _c.mutation.SetOperator(v) @@ -309,33 +237,6 @@ func (_c *LossLedgerCreate) check() error { return &ValidationError{Name: "workOrderNo", err: fmt.Errorf(`ent: validator failed for field "LossLedger.workOrderNo": %w`, err)} } } - if _, ok := _c.mutation.Status(); !ok { - return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "LossLedger.status"`)} - } - if v, ok := _c.mutation.Status(); ok { - if err := lossledger.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "LossLedger.status": %w`, err)} - } - } - if _, ok := _c.mutation.Comment(); !ok { - return &ValidationError{Name: "comment", err: errors.New(`ent: missing required field "LossLedger.comment"`)} - } - if v, ok := _c.mutation.Comment(); ok { - if err := lossledger.CommentValidator(v); err != nil { - return &ValidationError{Name: "comment", err: fmt.Errorf(`ent: validator failed for field "LossLedger.comment": %w`, err)} - } - } - if _, ok := _c.mutation.Commenter(); !ok { - return &ValidationError{Name: "commenter", err: errors.New(`ent: missing required field "LossLedger.commenter"`)} - } - if v, ok := _c.mutation.Commenter(); ok { - if err := lossledger.CommenterValidator(v); err != nil { - return &ValidationError{Name: "commenter", err: fmt.Errorf(`ent: validator failed for field "LossLedger.commenter": %w`, err)} - } - } - if _, ok := _c.mutation.CommentedAt(); !ok { - return &ValidationError{Name: "commentedAt", err: errors.New(`ent: missing required field "LossLedger.commentedAt"`)} - } if _, ok := _c.mutation.Operator(); !ok { return &ValidationError{Name: "operator", err: errors.New(`ent: missing required field "LossLedger.operator"`)} } @@ -409,22 +310,6 @@ func (_c *LossLedgerCreate) createSpec() (*LossLedger, *sqlgraph.CreateSpec) { _spec.SetField(lossledger.FieldWorkOrderNo, field.TypeString, value) _node.WorkOrderNo = value } - if value, ok := _c.mutation.Status(); ok { - _spec.SetField(lossledger.FieldStatus, field.TypeString, value) - _node.Status = value - } - if value, ok := _c.mutation.Comment(); ok { - _spec.SetField(lossledger.FieldComment, field.TypeString, value) - _node.Comment = value - } - if value, ok := _c.mutation.Commenter(); ok { - _spec.SetField(lossledger.FieldCommenter, field.TypeString, value) - _node.Commenter = value - } - if value, ok := _c.mutation.CommentedAt(); ok { - _spec.SetField(lossledger.FieldCommentedAt, field.TypeInt64, value) - _node.CommentedAt = value - } if value, ok := _c.mutation.Operator(); ok { _spec.SetField(lossledger.FieldOperator, field.TypeString, value) _node.Operator = value diff --git a/bj_power_mes/ent/lossledger_update.go b/bj_power_mes/ent/lossledger_update.go index 61811f4..fa39f68 100644 --- a/bj_power_mes/ent/lossledger_update.go +++ b/bj_power_mes/ent/lossledger_update.go @@ -182,69 +182,6 @@ func (_u *LossLedgerUpdate) SetNillableWorkOrderNo(v *string) *LossLedgerUpdate return _u } -// SetStatus sets the "status" field. -func (_u *LossLedgerUpdate) SetStatus(v string) *LossLedgerUpdate { - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *LossLedgerUpdate) SetNillableStatus(v *string) *LossLedgerUpdate { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// SetComment sets the "comment" field. -func (_u *LossLedgerUpdate) SetComment(v string) *LossLedgerUpdate { - _u.mutation.SetComment(v) - return _u -} - -// SetNillableComment sets the "comment" field if the given value is not nil. -func (_u *LossLedgerUpdate) SetNillableComment(v *string) *LossLedgerUpdate { - if v != nil { - _u.SetComment(*v) - } - return _u -} - -// SetCommenter sets the "commenter" field. -func (_u *LossLedgerUpdate) SetCommenter(v string) *LossLedgerUpdate { - _u.mutation.SetCommenter(v) - return _u -} - -// SetNillableCommenter sets the "commenter" field if the given value is not nil. -func (_u *LossLedgerUpdate) SetNillableCommenter(v *string) *LossLedgerUpdate { - if v != nil { - _u.SetCommenter(*v) - } - return _u -} - -// SetCommentedAt sets the "commentedAt" field. -func (_u *LossLedgerUpdate) SetCommentedAt(v int64) *LossLedgerUpdate { - _u.mutation.ResetCommentedAt() - _u.mutation.SetCommentedAt(v) - return _u -} - -// SetNillableCommentedAt sets the "commentedAt" field if the given value is not nil. -func (_u *LossLedgerUpdate) SetNillableCommentedAt(v *int64) *LossLedgerUpdate { - if v != nil { - _u.SetCommentedAt(*v) - } - return _u -} - -// AddCommentedAt adds value to the "commentedAt" field. -func (_u *LossLedgerUpdate) AddCommentedAt(v int64) *LossLedgerUpdate { - _u.mutation.AddCommentedAt(v) - return _u -} - // SetOperator sets the "operator" field. func (_u *LossLedgerUpdate) SetOperator(v string) *LossLedgerUpdate { _u.mutation.SetOperator(v) @@ -318,21 +255,6 @@ func (_u *LossLedgerUpdate) check() error { return &ValidationError{Name: "workOrderNo", err: fmt.Errorf(`ent: validator failed for field "LossLedger.workOrderNo": %w`, err)} } } - if v, ok := _u.mutation.Status(); ok { - if err := lossledger.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "LossLedger.status": %w`, err)} - } - } - if v, ok := _u.mutation.Comment(); ok { - if err := lossledger.CommentValidator(v); err != nil { - return &ValidationError{Name: "comment", err: fmt.Errorf(`ent: validator failed for field "LossLedger.comment": %w`, err)} - } - } - if v, ok := _u.mutation.Commenter(); ok { - if err := lossledger.CommenterValidator(v); err != nil { - return &ValidationError{Name: "commenter", err: fmt.Errorf(`ent: validator failed for field "LossLedger.commenter": %w`, err)} - } - } if v, ok := _u.mutation.Operator(); ok { if err := lossledger.OperatorValidator(v); err != nil { return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "LossLedger.operator": %w`, err)} @@ -398,21 +320,6 @@ func (_u *LossLedgerUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.WorkOrderNo(); ok { _spec.SetField(lossledger.FieldWorkOrderNo, field.TypeString, value) } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(lossledger.FieldStatus, field.TypeString, value) - } - if value, ok := _u.mutation.Comment(); ok { - _spec.SetField(lossledger.FieldComment, field.TypeString, value) - } - if value, ok := _u.mutation.Commenter(); ok { - _spec.SetField(lossledger.FieldCommenter, field.TypeString, value) - } - if value, ok := _u.mutation.CommentedAt(); ok { - _spec.SetField(lossledger.FieldCommentedAt, field.TypeInt64, value) - } - if value, ok := _u.mutation.AddedCommentedAt(); ok { - _spec.AddField(lossledger.FieldCommentedAt, field.TypeInt64, value) - } if value, ok := _u.mutation.Operator(); ok { _spec.SetField(lossledger.FieldOperator, field.TypeString, value) } @@ -592,69 +499,6 @@ func (_u *LossLedgerUpdateOne) SetNillableWorkOrderNo(v *string) *LossLedgerUpda return _u } -// SetStatus sets the "status" field. -func (_u *LossLedgerUpdateOne) SetStatus(v string) *LossLedgerUpdateOne { - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *LossLedgerUpdateOne) SetNillableStatus(v *string) *LossLedgerUpdateOne { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// SetComment sets the "comment" field. -func (_u *LossLedgerUpdateOne) SetComment(v string) *LossLedgerUpdateOne { - _u.mutation.SetComment(v) - return _u -} - -// SetNillableComment sets the "comment" field if the given value is not nil. -func (_u *LossLedgerUpdateOne) SetNillableComment(v *string) *LossLedgerUpdateOne { - if v != nil { - _u.SetComment(*v) - } - return _u -} - -// SetCommenter sets the "commenter" field. -func (_u *LossLedgerUpdateOne) SetCommenter(v string) *LossLedgerUpdateOne { - _u.mutation.SetCommenter(v) - return _u -} - -// SetNillableCommenter sets the "commenter" field if the given value is not nil. -func (_u *LossLedgerUpdateOne) SetNillableCommenter(v *string) *LossLedgerUpdateOne { - if v != nil { - _u.SetCommenter(*v) - } - return _u -} - -// SetCommentedAt sets the "commentedAt" field. -func (_u *LossLedgerUpdateOne) SetCommentedAt(v int64) *LossLedgerUpdateOne { - _u.mutation.ResetCommentedAt() - _u.mutation.SetCommentedAt(v) - return _u -} - -// SetNillableCommentedAt sets the "commentedAt" field if the given value is not nil. -func (_u *LossLedgerUpdateOne) SetNillableCommentedAt(v *int64) *LossLedgerUpdateOne { - if v != nil { - _u.SetCommentedAt(*v) - } - return _u -} - -// AddCommentedAt adds value to the "commentedAt" field. -func (_u *LossLedgerUpdateOne) AddCommentedAt(v int64) *LossLedgerUpdateOne { - _u.mutation.AddCommentedAt(v) - return _u -} - // SetOperator sets the "operator" field. func (_u *LossLedgerUpdateOne) SetOperator(v string) *LossLedgerUpdateOne { _u.mutation.SetOperator(v) @@ -741,21 +585,6 @@ func (_u *LossLedgerUpdateOne) check() error { return &ValidationError{Name: "workOrderNo", err: fmt.Errorf(`ent: validator failed for field "LossLedger.workOrderNo": %w`, err)} } } - if v, ok := _u.mutation.Status(); ok { - if err := lossledger.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "LossLedger.status": %w`, err)} - } - } - if v, ok := _u.mutation.Comment(); ok { - if err := lossledger.CommentValidator(v); err != nil { - return &ValidationError{Name: "comment", err: fmt.Errorf(`ent: validator failed for field "LossLedger.comment": %w`, err)} - } - } - if v, ok := _u.mutation.Commenter(); ok { - if err := lossledger.CommenterValidator(v); err != nil { - return &ValidationError{Name: "commenter", err: fmt.Errorf(`ent: validator failed for field "LossLedger.commenter": %w`, err)} - } - } if v, ok := _u.mutation.Operator(); ok { if err := lossledger.OperatorValidator(v); err != nil { return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "LossLedger.operator": %w`, err)} @@ -838,21 +667,6 @@ func (_u *LossLedgerUpdateOne) sqlSave(ctx context.Context) (_node *LossLedger, if value, ok := _u.mutation.WorkOrderNo(); ok { _spec.SetField(lossledger.FieldWorkOrderNo, field.TypeString, value) } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(lossledger.FieldStatus, field.TypeString, value) - } - if value, ok := _u.mutation.Comment(); ok { - _spec.SetField(lossledger.FieldComment, field.TypeString, value) - } - if value, ok := _u.mutation.Commenter(); ok { - _spec.SetField(lossledger.FieldCommenter, field.TypeString, value) - } - if value, ok := _u.mutation.CommentedAt(); ok { - _spec.SetField(lossledger.FieldCommentedAt, field.TypeInt64, value) - } - if value, ok := _u.mutation.AddedCommentedAt(); ok { - _spec.AddField(lossledger.FieldCommentedAt, field.TypeInt64, value) - } if value, ok := _u.mutation.Operator(); ok { _spec.SetField(lossledger.FieldOperator, field.TypeString, value) } diff --git a/bj_power_mes/ent/migrate/schema.go b/bj_power_mes/ent/migrate/schema.go index 56273c8..3931772 100644 --- a/bj_power_mes/ent/migrate/schema.go +++ b/bj_power_mes/ent/migrate/schema.go @@ -353,6 +353,7 @@ var ( {Name: "completed_qty", Type: field.TypeInt, Comment: "已完成数量", Default: 0}, {Name: "station_plan_qty", Type: field.TypeJSON, Nullable: true, Comment: "各工位产量分配 stationNo→计划产量", SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "status", Type: field.TypeString, Size: 20, Default: "PENDING"}, + {Name: "discarded", Type: field.TypeBool, Comment: "废弃标记:停用后置true,待启用的PENDING为false", Default: false}, {Name: "operator", Type: field.TypeString, Size: 64, Default: ""}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, @@ -553,17 +554,13 @@ var ( {Name: "reason", Type: field.TypeString, Size: 200, Comment: "损耗原因(必填)"}, {Name: "return_no", Type: field.TypeString, Size: 64, Comment: "关联退库单号(material_request.requestNo)", Default: ""}, {Name: "work_order_no", Type: field.TypeString, Size: 64, Comment: "关联工单号(可空)", Default: ""}, - {Name: "status", Type: field.TypeString, Size: 20, Comment: "PENDING待批注/COMMENTED已批注", Default: "PENDING"}, - {Name: "comment", Type: field.TypeString, Size: 300, Comment: "主管批注回复", Default: ""}, - {Name: "commenter", Type: field.TypeString, Size: 64, Comment: "批注人", Default: ""}, - {Name: "commented_at", Type: field.TypeInt64, Comment: "批注时间 unix秒", Default: 0}, {Name: "operator", Type: field.TypeString, Size: 64, Comment: "退料操作人", Default: ""}, {Name: "created_at", Type: field.TypeTime}, } // LossLedgersTable holds the schema information for the "loss_ledgers" table. LossLedgersTable = &schema.Table{ Name: "loss_ledgers", - Comment: "LossLedger 损耗台账:退料差额自动落账,主管批注(后审核)。", + Comment: "LossLedger 损耗台账:退料差额自动落账,只读(2026-11-27 取消批注)。", Columns: LossLedgersColumns, PrimaryKey: []*schema.Column{LossLedgersColumns[0]}, Indexes: []*schema.Index{ @@ -572,11 +569,6 @@ var ( Unique: false, Columns: []*schema.Column{LossLedgersColumns[1]}, }, - { - Name: "lossledger_status", - Unique: false, - Columns: []*schema.Column{LossLedgersColumns[10]}, - }, { Name: "lossledger_return_no", Unique: false, @@ -1157,6 +1149,71 @@ var ( }, }, } + // StationTerminalEventColumns holds the columns for the "station_terminal_event" table. + StationTerminalEventColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "station_no", Type: field.TypeInt, Comment: "工位号"}, + {Name: "event", Type: field.TypeString, Size: 32, Comment: "事件:stream_on/stream_off/login/logout/pause/resume/heartbeat"}, + {Name: "logged_in", Type: field.TypeBool, Comment: "事件后登录态", Default: false}, + {Name: "powered", Type: field.TypeBool, Comment: "事件后开机态", Default: false}, + {Name: "operator", Type: field.TypeString, Size: 64, Comment: "操作人", Default: ""}, + {Name: "detail", Type: field.TypeString, Size: 255, Comment: "补充说明", Default: ""}, + {Name: "created_at", Type: field.TypeInt64, Comment: "事件时间 unix秒", Default: 0}, + } + // StationTerminalEventTable holds the schema information for the "station_terminal_event" table. + StationTerminalEventTable = &schema.Table{ + Name: "station_terminal_event", + Comment: "StationTerminalEvent 工位终端状态变化流水(只增)。", + Columns: StationTerminalEventColumns, + PrimaryKey: []*schema.Column{StationTerminalEventColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "stationterminalevent_station_no", + Unique: false, + Columns: []*schema.Column{StationTerminalEventColumns[1]}, + }, + { + Name: "stationterminalevent_event", + Unique: false, + Columns: []*schema.Column{StationTerminalEventColumns[2]}, + }, + { + Name: "stationterminalevent_created_at", + Unique: false, + Columns: []*schema.Column{StationTerminalEventColumns[7]}, + }, + }, + } + // StationTerminalStateColumns holds the columns for the "station_terminal_state" table. + StationTerminalStateColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "station_no", Type: field.TypeInt, Comment: "工位号"}, + {Name: "powered", Type: field.TypeBool, Comment: "终端是否在线(SSE 建连 stream_on 置 true,断连 stream_off 置 false)", Default: false}, + {Name: "logged_in", Type: field.TypeBool, Comment: "该工位是否有登录会话(终端上报登录=是/退出=否)", Default: false}, + {Name: "operator", Type: field.TypeString, Size: 64, Comment: "当前登录人(终端上报;无会话为空)", Default: ""}, + {Name: "paused", Type: field.TypeBool, Comment: "是否暂停接单(终端上报暂停/恢复)", Default: false}, + {Name: "last_heartbeat_at", Type: field.TypeInt64, Comment: "最近一次 SSE ping 心跳时间 unix秒(0=从未连接)", Default: 0}, + {Name: "updated_at", Type: field.TypeInt64, Comment: "状态更新时间 unix秒", Default: 0}, + } + // StationTerminalStateTable holds the schema information for the "station_terminal_state" table. + StationTerminalStateTable = &schema.Table{ + Name: "station_terminal_state", + Comment: "StationTerminalState 工位终端当前状态(上报镜像+心跳)。", + Columns: StationTerminalStateColumns, + PrimaryKey: []*schema.Column{StationTerminalStateColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "stationterminalstate_station_no", + Unique: true, + Columns: []*schema.Column{StationTerminalStateColumns[1]}, + }, + { + Name: "stationterminalstate_last_heartbeat_at", + Unique: false, + Columns: []*schema.Column{StationTerminalStateColumns[6]}, + }, + }, + } // StepCriterionColumns holds the columns for the "step_criterion" table. StepCriterionColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -1714,6 +1771,8 @@ var ( StationTable, StationShiftsTable, StationStateTable, + StationTerminalEventTable, + StationTerminalStateTable, StepCriterionTable, StepDataTable, StepSignRecordTable, @@ -1828,6 +1887,12 @@ func init() { StationStateTable.Annotation = &entsql.Annotation{ Table: "station_state", } + StationTerminalEventTable.Annotation = &entsql.Annotation{ + Table: "station_terminal_event", + } + StationTerminalStateTable.Annotation = &entsql.Annotation{ + Table: "station_terminal_state", + } StepCriterionTable.Annotation = &entsql.Annotation{ Table: "step_criterion", } diff --git a/bj_power_mes/ent/mutation.go b/bj_power_mes/ent/mutation.go index dc0a6a8..1e0828a 100644 --- a/bj_power_mes/ent/mutation.go +++ b/bj_power_mes/ent/mutation.go @@ -36,6 +36,8 @@ import ( "bj_power_mes/ent/station" "bj_power_mes/ent/stationshift" "bj_power_mes/ent/stationstate" + "bj_power_mes/ent/stationterminalevent" + "bj_power_mes/ent/stationterminalstate" "bj_power_mes/ent/stepcriterion" "bj_power_mes/ent/stepdata" "bj_power_mes/ent/stepsignrecord" @@ -102,6 +104,8 @@ const ( TypeStation = "Station" TypeStationShift = "StationShift" TypeStationState = "StationState" + TypeStationTerminalEvent = "StationTerminalEvent" + TypeStationTerminalState = "StationTerminalState" TypeStepCriterion = "StepCriterion" TypeStepData = "StepData" TypeStepSignRecord = "StepSignRecord" @@ -9552,6 +9556,7 @@ type DailyPlanMutation struct { addcompletedQty *int stationPlanQty *map[string]int status *string + discarded *bool operator *string createdAt *time.Time updatedAt *time.Time @@ -9934,6 +9939,42 @@ func (m *DailyPlanMutation) ResetStatus() { m.status = nil } +// SetDiscarded sets the "discarded" field. +func (m *DailyPlanMutation) SetDiscarded(b bool) { + m.discarded = &b +} + +// Discarded returns the value of the "discarded" field in the mutation. +func (m *DailyPlanMutation) Discarded() (r bool, exists bool) { + v := m.discarded + if v == nil { + return + } + return *v, true +} + +// OldDiscarded returns the old "discarded" field's value of the DailyPlan entity. +// If the DailyPlan 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 *DailyPlanMutation) OldDiscarded(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDiscarded is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDiscarded requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDiscarded: %w", err) + } + return oldValue.Discarded, nil +} + +// ResetDiscarded resets all changes to the "discarded" field. +func (m *DailyPlanMutation) ResetDiscarded() { + m.discarded = nil +} + // SetOperator sets the "operator" field. func (m *DailyPlanMutation) SetOperator(s string) { m.operator = &s @@ -10089,7 +10130,7 @@ func (m *DailyPlanMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *DailyPlanMutation) Fields() []string { - fields := make([]string, 0, 9) + fields := make([]string, 0, 10) if m.orderNo != nil { fields = append(fields, dailyplan.FieldOrderNo) } @@ -10108,6 +10149,9 @@ func (m *DailyPlanMutation) Fields() []string { if m.status != nil { fields = append(fields, dailyplan.FieldStatus) } + if m.discarded != nil { + fields = append(fields, dailyplan.FieldDiscarded) + } if m.operator != nil { fields = append(fields, dailyplan.FieldOperator) } @@ -10137,6 +10181,8 @@ func (m *DailyPlanMutation) Field(name string) (ent.Value, bool) { return m.StationPlanQty() case dailyplan.FieldStatus: return m.Status() + case dailyplan.FieldDiscarded: + return m.Discarded() case dailyplan.FieldOperator: return m.Operator() case dailyplan.FieldCreatedAt: @@ -10164,6 +10210,8 @@ func (m *DailyPlanMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldStationPlanQty(ctx) case dailyplan.FieldStatus: return m.OldStatus(ctx) + case dailyplan.FieldDiscarded: + return m.OldDiscarded(ctx) case dailyplan.FieldOperator: return m.OldOperator(ctx) case dailyplan.FieldCreatedAt: @@ -10221,6 +10269,13 @@ func (m *DailyPlanMutation) SetField(name string, value ent.Value) error { } m.SetStatus(v) return nil + case dailyplan.FieldDiscarded: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDiscarded(v) + return nil case dailyplan.FieldOperator: v, ok := value.(string) if !ok { @@ -10351,6 +10406,9 @@ func (m *DailyPlanMutation) ResetField(name string) error { case dailyplan.FieldStatus: m.ResetStatus() return nil + case dailyplan.FieldDiscarded: + m.ResetDiscarded() + return nil case dailyplan.FieldOperator: m.ResetOperator() return nil @@ -14697,33 +14755,28 @@ func (m *LinePointMutation) ResetEdge(name string) error { // LossLedgerMutation represents an operation that mutates the LossLedger nodes in the graph. type LossLedgerMutation struct { config - op Op - typ string - id *int - stationNo *int - addstationNo *int - materialCode *string - materialName *string - theoryQty *float64 - addtheoryQty *float64 - actualQty *float64 - addactualQty *float64 - lossQty *float64 - addlossQty *float64 - reason *string - returnNo *string - workOrderNo *string - status *string - comment *string - commenter *string - commentedAt *int64 - addcommentedAt *int64 - operator *string - createdAt *time.Time - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*LossLedger, error) - predicates []predicate.LossLedger + op Op + typ string + id *int + stationNo *int + addstationNo *int + materialCode *string + materialName *string + theoryQty *float64 + addtheoryQty *float64 + actualQty *float64 + addactualQty *float64 + lossQty *float64 + addlossQty *float64 + reason *string + returnNo *string + workOrderNo *string + operator *string + createdAt *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*LossLedger, error) + predicates []predicate.LossLedger } var _ ent.Mutation = (*LossLedgerMutation)(nil) @@ -15228,170 +15281,6 @@ func (m *LossLedgerMutation) ResetWorkOrderNo() { m.workOrderNo = nil } -// SetStatus sets the "status" field. -func (m *LossLedgerMutation) SetStatus(s string) { - m.status = &s -} - -// Status returns the value of the "status" field in the mutation. -func (m *LossLedgerMutation) Status() (r string, exists bool) { - v := m.status - if v == nil { - return - } - return *v, true -} - -// OldStatus returns the old "status" field's value of the LossLedger entity. -// If the LossLedger 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 *LossLedgerMutation) OldStatus(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) - } - return oldValue.Status, nil -} - -// ResetStatus resets all changes to the "status" field. -func (m *LossLedgerMutation) ResetStatus() { - m.status = nil -} - -// SetComment sets the "comment" field. -func (m *LossLedgerMutation) SetComment(s string) { - m.comment = &s -} - -// Comment returns the value of the "comment" field in the mutation. -func (m *LossLedgerMutation) Comment() (r string, exists bool) { - v := m.comment - if v == nil { - return - } - return *v, true -} - -// OldComment returns the old "comment" field's value of the LossLedger entity. -// If the LossLedger 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 *LossLedgerMutation) OldComment(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldComment is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldComment requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldComment: %w", err) - } - return oldValue.Comment, nil -} - -// ResetComment resets all changes to the "comment" field. -func (m *LossLedgerMutation) ResetComment() { - m.comment = nil -} - -// SetCommenter sets the "commenter" field. -func (m *LossLedgerMutation) SetCommenter(s string) { - m.commenter = &s -} - -// Commenter returns the value of the "commenter" field in the mutation. -func (m *LossLedgerMutation) Commenter() (r string, exists bool) { - v := m.commenter - if v == nil { - return - } - return *v, true -} - -// OldCommenter returns the old "commenter" field's value of the LossLedger entity. -// If the LossLedger 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 *LossLedgerMutation) OldCommenter(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCommenter is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCommenter requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCommenter: %w", err) - } - return oldValue.Commenter, nil -} - -// ResetCommenter resets all changes to the "commenter" field. -func (m *LossLedgerMutation) ResetCommenter() { - m.commenter = nil -} - -// SetCommentedAt sets the "commentedAt" field. -func (m *LossLedgerMutation) SetCommentedAt(i int64) { - m.commentedAt = &i - m.addcommentedAt = nil -} - -// CommentedAt returns the value of the "commentedAt" field in the mutation. -func (m *LossLedgerMutation) CommentedAt() (r int64, exists bool) { - v := m.commentedAt - if v == nil { - return - } - return *v, true -} - -// OldCommentedAt returns the old "commentedAt" field's value of the LossLedger entity. -// If the LossLedger 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 *LossLedgerMutation) OldCommentedAt(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCommentedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCommentedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCommentedAt: %w", err) - } - return oldValue.CommentedAt, nil -} - -// AddCommentedAt adds i to the "commentedAt" field. -func (m *LossLedgerMutation) AddCommentedAt(i int64) { - if m.addcommentedAt != nil { - *m.addcommentedAt += i - } else { - m.addcommentedAt = &i - } -} - -// AddedCommentedAt returns the value that was added to the "commentedAt" field in this mutation. -func (m *LossLedgerMutation) AddedCommentedAt() (r int64, exists bool) { - v := m.addcommentedAt - if v == nil { - return - } - return *v, true -} - -// ResetCommentedAt resets all changes to the "commentedAt" field. -func (m *LossLedgerMutation) ResetCommentedAt() { - m.commentedAt = nil - m.addcommentedAt = nil -} - // SetOperator sets the "operator" field. func (m *LossLedgerMutation) SetOperator(s string) { m.operator = &s @@ -15498,7 +15387,7 @@ func (m *LossLedgerMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *LossLedgerMutation) Fields() []string { - fields := make([]string, 0, 15) + fields := make([]string, 0, 11) if m.stationNo != nil { fields = append(fields, lossledger.FieldStationNo) } @@ -15526,18 +15415,6 @@ func (m *LossLedgerMutation) Fields() []string { if m.workOrderNo != nil { fields = append(fields, lossledger.FieldWorkOrderNo) } - if m.status != nil { - fields = append(fields, lossledger.FieldStatus) - } - if m.comment != nil { - fields = append(fields, lossledger.FieldComment) - } - if m.commenter != nil { - fields = append(fields, lossledger.FieldCommenter) - } - if m.commentedAt != nil { - fields = append(fields, lossledger.FieldCommentedAt) - } if m.operator != nil { fields = append(fields, lossledger.FieldOperator) } @@ -15570,14 +15447,6 @@ func (m *LossLedgerMutation) Field(name string) (ent.Value, bool) { return m.ReturnNo() case lossledger.FieldWorkOrderNo: return m.WorkOrderNo() - case lossledger.FieldStatus: - return m.Status() - case lossledger.FieldComment: - return m.Comment() - case lossledger.FieldCommenter: - return m.Commenter() - case lossledger.FieldCommentedAt: - return m.CommentedAt() case lossledger.FieldOperator: return m.Operator() case lossledger.FieldCreatedAt: @@ -15609,14 +15478,6 @@ func (m *LossLedgerMutation) OldField(ctx context.Context, name string) (ent.Val return m.OldReturnNo(ctx) case lossledger.FieldWorkOrderNo: return m.OldWorkOrderNo(ctx) - case lossledger.FieldStatus: - return m.OldStatus(ctx) - case lossledger.FieldComment: - return m.OldComment(ctx) - case lossledger.FieldCommenter: - return m.OldCommenter(ctx) - case lossledger.FieldCommentedAt: - return m.OldCommentedAt(ctx) case lossledger.FieldOperator: return m.OldOperator(ctx) case lossledger.FieldCreatedAt: @@ -15693,34 +15554,6 @@ func (m *LossLedgerMutation) SetField(name string, value ent.Value) error { } m.SetWorkOrderNo(v) return nil - case lossledger.FieldStatus: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetStatus(v) - return nil - case lossledger.FieldComment: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetComment(v) - return nil - case lossledger.FieldCommenter: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCommenter(v) - return nil - case lossledger.FieldCommentedAt: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCommentedAt(v) - return nil case lossledger.FieldOperator: v, ok := value.(string) if !ok { @@ -15755,9 +15588,6 @@ func (m *LossLedgerMutation) AddedFields() []string { if m.addlossQty != nil { fields = append(fields, lossledger.FieldLossQty) } - if m.addcommentedAt != nil { - fields = append(fields, lossledger.FieldCommentedAt) - } return fields } @@ -15774,8 +15604,6 @@ func (m *LossLedgerMutation) AddedField(name string) (ent.Value, bool) { return m.AddedActualQty() case lossledger.FieldLossQty: return m.AddedLossQty() - case lossledger.FieldCommentedAt: - return m.AddedCommentedAt() } return nil, false } @@ -15813,13 +15641,6 @@ func (m *LossLedgerMutation) AddField(name string, value ent.Value) error { } m.AddLossQty(v) return nil - case lossledger.FieldCommentedAt: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddCommentedAt(v) - return nil } return fmt.Errorf("unknown LossLedger numeric field %s", name) } @@ -15874,18 +15695,6 @@ func (m *LossLedgerMutation) ResetField(name string) error { case lossledger.FieldWorkOrderNo: m.ResetWorkOrderNo() return nil - case lossledger.FieldStatus: - m.ResetStatus() - return nil - case lossledger.FieldComment: - m.ResetComment() - return nil - case lossledger.FieldCommenter: - m.ResetCommenter() - return nil - case lossledger.FieldCommentedAt: - m.ResetCommentedAt() - return nil case lossledger.FieldOperator: m.ResetOperator() return nil @@ -32493,6 +32302,1489 @@ func (m *StationStateMutation) ResetEdge(name string) error { return fmt.Errorf("unknown StationState edge %s", name) } +// StationTerminalEventMutation represents an operation that mutates the StationTerminalEvent nodes in the graph. +type StationTerminalEventMutation struct { + config + op Op + typ string + id *int + stationNo *int + addstationNo *int + event *string + loggedIn *bool + powered *bool + operator *string + detail *string + createdAt *int64 + addcreatedAt *int64 + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*StationTerminalEvent, error) + predicates []predicate.StationTerminalEvent +} + +var _ ent.Mutation = (*StationTerminalEventMutation)(nil) + +// stationterminaleventOption allows management of the mutation configuration using functional options. +type stationterminaleventOption func(*StationTerminalEventMutation) + +// newStationTerminalEventMutation creates new mutation for the StationTerminalEvent entity. +func newStationTerminalEventMutation(c config, op Op, opts ...stationterminaleventOption) *StationTerminalEventMutation { + m := &StationTerminalEventMutation{ + config: c, + op: op, + typ: TypeStationTerminalEvent, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withStationTerminalEventID sets the ID field of the mutation. +func withStationTerminalEventID(id int) stationterminaleventOption { + return func(m *StationTerminalEventMutation) { + var ( + err error + once sync.Once + value *StationTerminalEvent + ) + m.oldValue = func(ctx context.Context) (*StationTerminalEvent, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().StationTerminalEvent.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withStationTerminalEvent sets the old StationTerminalEvent of the mutation. +func withStationTerminalEvent(node *StationTerminalEvent) stationterminaleventOption { + return func(m *StationTerminalEventMutation) { + m.oldValue = func(context.Context) (*StationTerminalEvent, 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 StationTerminalEventMutation) 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 StationTerminalEventMutation) 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 StationTerminalEvent entities. +func (m *StationTerminalEventMutation) 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 *StationTerminalEventMutation) 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 *StationTerminalEventMutation) 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().StationTerminalEvent.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetStationNo sets the "stationNo" field. +func (m *StationTerminalEventMutation) SetStationNo(i int) { + m.stationNo = &i + m.addstationNo = nil +} + +// StationNo returns the value of the "stationNo" field in the mutation. +func (m *StationTerminalEventMutation) StationNo() (r int, exists bool) { + v := m.stationNo + if v == nil { + return + } + return *v, true +} + +// OldStationNo returns the old "stationNo" field's value of the StationTerminalEvent entity. +// If the StationTerminalEvent 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 *StationTerminalEventMutation) OldStationNo(ctx context.Context) (v int, 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 +} + +// AddStationNo adds i to the "stationNo" field. +func (m *StationTerminalEventMutation) AddStationNo(i int) { + if m.addstationNo != nil { + *m.addstationNo += i + } else { + m.addstationNo = &i + } +} + +// AddedStationNo returns the value that was added to the "stationNo" field in this mutation. +func (m *StationTerminalEventMutation) AddedStationNo() (r int, exists bool) { + v := m.addstationNo + if v == nil { + return + } + return *v, true +} + +// ResetStationNo resets all changes to the "stationNo" field. +func (m *StationTerminalEventMutation) ResetStationNo() { + m.stationNo = nil + m.addstationNo = nil +} + +// SetEvent sets the "event" field. +func (m *StationTerminalEventMutation) SetEvent(s string) { + m.event = &s +} + +// Event returns the value of the "event" field in the mutation. +func (m *StationTerminalEventMutation) Event() (r string, exists bool) { + v := m.event + if v == nil { + return + } + return *v, true +} + +// OldEvent returns the old "event" field's value of the StationTerminalEvent entity. +// If the StationTerminalEvent 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 *StationTerminalEventMutation) OldEvent(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEvent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEvent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEvent: %w", err) + } + return oldValue.Event, nil +} + +// ResetEvent resets all changes to the "event" field. +func (m *StationTerminalEventMutation) ResetEvent() { + m.event = nil +} + +// SetLoggedIn sets the "loggedIn" field. +func (m *StationTerminalEventMutation) SetLoggedIn(b bool) { + m.loggedIn = &b +} + +// LoggedIn returns the value of the "loggedIn" field in the mutation. +func (m *StationTerminalEventMutation) LoggedIn() (r bool, exists bool) { + v := m.loggedIn + if v == nil { + return + } + return *v, true +} + +// OldLoggedIn returns the old "loggedIn" field's value of the StationTerminalEvent entity. +// If the StationTerminalEvent 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 *StationTerminalEventMutation) OldLoggedIn(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoggedIn is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoggedIn requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoggedIn: %w", err) + } + return oldValue.LoggedIn, nil +} + +// ResetLoggedIn resets all changes to the "loggedIn" field. +func (m *StationTerminalEventMutation) ResetLoggedIn() { + m.loggedIn = nil +} + +// SetPowered sets the "powered" field. +func (m *StationTerminalEventMutation) SetPowered(b bool) { + m.powered = &b +} + +// Powered returns the value of the "powered" field in the mutation. +func (m *StationTerminalEventMutation) Powered() (r bool, exists bool) { + v := m.powered + if v == nil { + return + } + return *v, true +} + +// OldPowered returns the old "powered" field's value of the StationTerminalEvent entity. +// If the StationTerminalEvent 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 *StationTerminalEventMutation) OldPowered(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPowered is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPowered requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPowered: %w", err) + } + return oldValue.Powered, nil +} + +// ResetPowered resets all changes to the "powered" field. +func (m *StationTerminalEventMutation) ResetPowered() { + m.powered = nil +} + +// SetOperator sets the "operator" field. +func (m *StationTerminalEventMutation) SetOperator(s string) { + m.operator = &s +} + +// Operator returns the value of the "operator" field in the mutation. +func (m *StationTerminalEventMutation) 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 StationTerminalEvent entity. +// If the StationTerminalEvent 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 *StationTerminalEventMutation) 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 *StationTerminalEventMutation) ResetOperator() { + m.operator = nil +} + +// SetDetail sets the "detail" field. +func (m *StationTerminalEventMutation) SetDetail(s string) { + m.detail = &s +} + +// Detail returns the value of the "detail" field in the mutation. +func (m *StationTerminalEventMutation) Detail() (r string, exists bool) { + v := m.detail + if v == nil { + return + } + return *v, true +} + +// OldDetail returns the old "detail" field's value of the StationTerminalEvent entity. +// If the StationTerminalEvent 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 *StationTerminalEventMutation) OldDetail(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDetail is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDetail requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDetail: %w", err) + } + return oldValue.Detail, nil +} + +// ResetDetail resets all changes to the "detail" field. +func (m *StationTerminalEventMutation) ResetDetail() { + m.detail = nil +} + +// SetCreatedAt sets the "createdAt" field. +func (m *StationTerminalEventMutation) SetCreatedAt(i int64) { + m.createdAt = &i + m.addcreatedAt = nil +} + +// CreatedAt returns the value of the "createdAt" field in the mutation. +func (m *StationTerminalEventMutation) CreatedAt() (r int64, exists bool) { + v := m.createdAt + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "createdAt" field's value of the StationTerminalEvent entity. +// If the StationTerminalEvent 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 *StationTerminalEventMutation) OldCreatedAt(ctx context.Context) (v int64, 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 +} + +// AddCreatedAt adds i to the "createdAt" field. +func (m *StationTerminalEventMutation) AddCreatedAt(i int64) { + if m.addcreatedAt != nil { + *m.addcreatedAt += i + } else { + m.addcreatedAt = &i + } +} + +// AddedCreatedAt returns the value that was added to the "createdAt" field in this mutation. +func (m *StationTerminalEventMutation) AddedCreatedAt() (r int64, exists bool) { + v := m.addcreatedAt + if v == nil { + return + } + return *v, true +} + +// ResetCreatedAt resets all changes to the "createdAt" field. +func (m *StationTerminalEventMutation) ResetCreatedAt() { + m.createdAt = nil + m.addcreatedAt = nil +} + +// Where appends a list predicates to the StationTerminalEventMutation builder. +func (m *StationTerminalEventMutation) Where(ps ...predicate.StationTerminalEvent) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the StationTerminalEventMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *StationTerminalEventMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.StationTerminalEvent, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *StationTerminalEventMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *StationTerminalEventMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (StationTerminalEvent). +func (m *StationTerminalEventMutation) 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 *StationTerminalEventMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.stationNo != nil { + fields = append(fields, stationterminalevent.FieldStationNo) + } + if m.event != nil { + fields = append(fields, stationterminalevent.FieldEvent) + } + if m.loggedIn != nil { + fields = append(fields, stationterminalevent.FieldLoggedIn) + } + if m.powered != nil { + fields = append(fields, stationterminalevent.FieldPowered) + } + if m.operator != nil { + fields = append(fields, stationterminalevent.FieldOperator) + } + if m.detail != nil { + fields = append(fields, stationterminalevent.FieldDetail) + } + if m.createdAt != nil { + fields = append(fields, stationterminalevent.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 *StationTerminalEventMutation) Field(name string) (ent.Value, bool) { + switch name { + case stationterminalevent.FieldStationNo: + return m.StationNo() + case stationterminalevent.FieldEvent: + return m.Event() + case stationterminalevent.FieldLoggedIn: + return m.LoggedIn() + case stationterminalevent.FieldPowered: + return m.Powered() + case stationterminalevent.FieldOperator: + return m.Operator() + case stationterminalevent.FieldDetail: + return m.Detail() + case stationterminalevent.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 *StationTerminalEventMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case stationterminalevent.FieldStationNo: + return m.OldStationNo(ctx) + case stationterminalevent.FieldEvent: + return m.OldEvent(ctx) + case stationterminalevent.FieldLoggedIn: + return m.OldLoggedIn(ctx) + case stationterminalevent.FieldPowered: + return m.OldPowered(ctx) + case stationterminalevent.FieldOperator: + return m.OldOperator(ctx) + case stationterminalevent.FieldDetail: + return m.OldDetail(ctx) + case stationterminalevent.FieldCreatedAt: + return m.OldCreatedAt(ctx) + } + return nil, fmt.Errorf("unknown StationTerminalEvent 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 *StationTerminalEventMutation) SetField(name string, value ent.Value) error { + switch name { + case stationterminalevent.FieldStationNo: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStationNo(v) + return nil + case stationterminalevent.FieldEvent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEvent(v) + return nil + case stationterminalevent.FieldLoggedIn: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoggedIn(v) + return nil + case stationterminalevent.FieldPowered: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPowered(v) + return nil + case stationterminalevent.FieldOperator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOperator(v) + return nil + case stationterminalevent.FieldDetail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDetail(v) + return nil + case stationterminalevent.FieldCreatedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown StationTerminalEvent field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *StationTerminalEventMutation) AddedFields() []string { + var fields []string + if m.addstationNo != nil { + fields = append(fields, stationterminalevent.FieldStationNo) + } + if m.addcreatedAt != nil { + fields = append(fields, stationterminalevent.FieldCreatedAt) + } + 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 *StationTerminalEventMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case stationterminalevent.FieldStationNo: + return m.AddedStationNo() + case stationterminalevent.FieldCreatedAt: + return m.AddedCreatedAt() + } + 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 *StationTerminalEventMutation) AddField(name string, value ent.Value) error { + switch name { + case stationterminalevent.FieldStationNo: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStationNo(v) + return nil + case stationterminalevent.FieldCreatedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCreatedAt(v) + return nil + } + return fmt.Errorf("unknown StationTerminalEvent numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *StationTerminalEventMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *StationTerminalEventMutation) 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 *StationTerminalEventMutation) ClearField(name string) error { + return fmt.Errorf("unknown StationTerminalEvent 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 *StationTerminalEventMutation) ResetField(name string) error { + switch name { + case stationterminalevent.FieldStationNo: + m.ResetStationNo() + return nil + case stationterminalevent.FieldEvent: + m.ResetEvent() + return nil + case stationterminalevent.FieldLoggedIn: + m.ResetLoggedIn() + return nil + case stationterminalevent.FieldPowered: + m.ResetPowered() + return nil + case stationterminalevent.FieldOperator: + m.ResetOperator() + return nil + case stationterminalevent.FieldDetail: + m.ResetDetail() + return nil + case stationterminalevent.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown StationTerminalEvent field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *StationTerminalEventMutation) 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 *StationTerminalEventMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *StationTerminalEventMutation) 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 *StationTerminalEventMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *StationTerminalEventMutation) 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 *StationTerminalEventMutation) 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 *StationTerminalEventMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown StationTerminalEvent 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 *StationTerminalEventMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown StationTerminalEvent edge %s", name) +} + +// StationTerminalStateMutation represents an operation that mutates the StationTerminalState nodes in the graph. +type StationTerminalStateMutation struct { + config + op Op + typ string + id *int + stationNo *int + addstationNo *int + powered *bool + loggedIn *bool + operator *string + paused *bool + lastHeartbeatAt *int64 + addlastHeartbeatAt *int64 + updatedAt *int64 + addupdatedAt *int64 + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*StationTerminalState, error) + predicates []predicate.StationTerminalState +} + +var _ ent.Mutation = (*StationTerminalStateMutation)(nil) + +// stationterminalstateOption allows management of the mutation configuration using functional options. +type stationterminalstateOption func(*StationTerminalStateMutation) + +// newStationTerminalStateMutation creates new mutation for the StationTerminalState entity. +func newStationTerminalStateMutation(c config, op Op, opts ...stationterminalstateOption) *StationTerminalStateMutation { + m := &StationTerminalStateMutation{ + config: c, + op: op, + typ: TypeStationTerminalState, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withStationTerminalStateID sets the ID field of the mutation. +func withStationTerminalStateID(id int) stationterminalstateOption { + return func(m *StationTerminalStateMutation) { + var ( + err error + once sync.Once + value *StationTerminalState + ) + m.oldValue = func(ctx context.Context) (*StationTerminalState, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().StationTerminalState.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withStationTerminalState sets the old StationTerminalState of the mutation. +func withStationTerminalState(node *StationTerminalState) stationterminalstateOption { + return func(m *StationTerminalStateMutation) { + m.oldValue = func(context.Context) (*StationTerminalState, 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 StationTerminalStateMutation) 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 StationTerminalStateMutation) 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 StationTerminalState entities. +func (m *StationTerminalStateMutation) 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 *StationTerminalStateMutation) 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 *StationTerminalStateMutation) 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().StationTerminalState.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetStationNo sets the "stationNo" field. +func (m *StationTerminalStateMutation) SetStationNo(i int) { + m.stationNo = &i + m.addstationNo = nil +} + +// StationNo returns the value of the "stationNo" field in the mutation. +func (m *StationTerminalStateMutation) StationNo() (r int, exists bool) { + v := m.stationNo + if v == nil { + return + } + return *v, true +} + +// OldStationNo returns the old "stationNo" field's value of the StationTerminalState entity. +// If the StationTerminalState 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 *StationTerminalStateMutation) OldStationNo(ctx context.Context) (v int, 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 +} + +// AddStationNo adds i to the "stationNo" field. +func (m *StationTerminalStateMutation) AddStationNo(i int) { + if m.addstationNo != nil { + *m.addstationNo += i + } else { + m.addstationNo = &i + } +} + +// AddedStationNo returns the value that was added to the "stationNo" field in this mutation. +func (m *StationTerminalStateMutation) AddedStationNo() (r int, exists bool) { + v := m.addstationNo + if v == nil { + return + } + return *v, true +} + +// ResetStationNo resets all changes to the "stationNo" field. +func (m *StationTerminalStateMutation) ResetStationNo() { + m.stationNo = nil + m.addstationNo = nil +} + +// SetPowered sets the "powered" field. +func (m *StationTerminalStateMutation) SetPowered(b bool) { + m.powered = &b +} + +// Powered returns the value of the "powered" field in the mutation. +func (m *StationTerminalStateMutation) Powered() (r bool, exists bool) { + v := m.powered + if v == nil { + return + } + return *v, true +} + +// OldPowered returns the old "powered" field's value of the StationTerminalState entity. +// If the StationTerminalState 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 *StationTerminalStateMutation) OldPowered(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPowered is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPowered requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPowered: %w", err) + } + return oldValue.Powered, nil +} + +// ResetPowered resets all changes to the "powered" field. +func (m *StationTerminalStateMutation) ResetPowered() { + m.powered = nil +} + +// SetLoggedIn sets the "loggedIn" field. +func (m *StationTerminalStateMutation) SetLoggedIn(b bool) { + m.loggedIn = &b +} + +// LoggedIn returns the value of the "loggedIn" field in the mutation. +func (m *StationTerminalStateMutation) LoggedIn() (r bool, exists bool) { + v := m.loggedIn + if v == nil { + return + } + return *v, true +} + +// OldLoggedIn returns the old "loggedIn" field's value of the StationTerminalState entity. +// If the StationTerminalState 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 *StationTerminalStateMutation) OldLoggedIn(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoggedIn is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoggedIn requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoggedIn: %w", err) + } + return oldValue.LoggedIn, nil +} + +// ResetLoggedIn resets all changes to the "loggedIn" field. +func (m *StationTerminalStateMutation) ResetLoggedIn() { + m.loggedIn = nil +} + +// SetOperator sets the "operator" field. +func (m *StationTerminalStateMutation) SetOperator(s string) { + m.operator = &s +} + +// Operator returns the value of the "operator" field in the mutation. +func (m *StationTerminalStateMutation) 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 StationTerminalState entity. +// If the StationTerminalState 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 *StationTerminalStateMutation) 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 *StationTerminalStateMutation) ResetOperator() { + m.operator = nil +} + +// SetPaused sets the "paused" field. +func (m *StationTerminalStateMutation) SetPaused(b bool) { + m.paused = &b +} + +// Paused returns the value of the "paused" field in the mutation. +func (m *StationTerminalStateMutation) Paused() (r bool, exists bool) { + v := m.paused + if v == nil { + return + } + return *v, true +} + +// OldPaused returns the old "paused" field's value of the StationTerminalState entity. +// If the StationTerminalState 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 *StationTerminalStateMutation) OldPaused(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPaused is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPaused requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPaused: %w", err) + } + return oldValue.Paused, nil +} + +// ResetPaused resets all changes to the "paused" field. +func (m *StationTerminalStateMutation) ResetPaused() { + m.paused = nil +} + +// SetLastHeartbeatAt sets the "lastHeartbeatAt" field. +func (m *StationTerminalStateMutation) SetLastHeartbeatAt(i int64) { + m.lastHeartbeatAt = &i + m.addlastHeartbeatAt = nil +} + +// LastHeartbeatAt returns the value of the "lastHeartbeatAt" field in the mutation. +func (m *StationTerminalStateMutation) LastHeartbeatAt() (r int64, exists bool) { + v := m.lastHeartbeatAt + if v == nil { + return + } + return *v, true +} + +// OldLastHeartbeatAt returns the old "lastHeartbeatAt" field's value of the StationTerminalState entity. +// If the StationTerminalState 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 *StationTerminalStateMutation) OldLastHeartbeatAt(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastHeartbeatAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastHeartbeatAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastHeartbeatAt: %w", err) + } + return oldValue.LastHeartbeatAt, nil +} + +// AddLastHeartbeatAt adds i to the "lastHeartbeatAt" field. +func (m *StationTerminalStateMutation) AddLastHeartbeatAt(i int64) { + if m.addlastHeartbeatAt != nil { + *m.addlastHeartbeatAt += i + } else { + m.addlastHeartbeatAt = &i + } +} + +// AddedLastHeartbeatAt returns the value that was added to the "lastHeartbeatAt" field in this mutation. +func (m *StationTerminalStateMutation) AddedLastHeartbeatAt() (r int64, exists bool) { + v := m.addlastHeartbeatAt + if v == nil { + return + } + return *v, true +} + +// ResetLastHeartbeatAt resets all changes to the "lastHeartbeatAt" field. +func (m *StationTerminalStateMutation) ResetLastHeartbeatAt() { + m.lastHeartbeatAt = nil + m.addlastHeartbeatAt = nil +} + +// SetUpdatedAt sets the "updatedAt" field. +func (m *StationTerminalStateMutation) SetUpdatedAt(i int64) { + m.updatedAt = &i + m.addupdatedAt = nil +} + +// UpdatedAt returns the value of the "updatedAt" field in the mutation. +func (m *StationTerminalStateMutation) UpdatedAt() (r int64, exists bool) { + v := m.updatedAt + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updatedAt" field's value of the StationTerminalState entity. +// If the StationTerminalState 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 *StationTerminalStateMutation) OldUpdatedAt(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// AddUpdatedAt adds i to the "updatedAt" field. +func (m *StationTerminalStateMutation) AddUpdatedAt(i int64) { + if m.addupdatedAt != nil { + *m.addupdatedAt += i + } else { + m.addupdatedAt = &i + } +} + +// AddedUpdatedAt returns the value that was added to the "updatedAt" field in this mutation. +func (m *StationTerminalStateMutation) AddedUpdatedAt() (r int64, exists bool) { + v := m.addupdatedAt + if v == nil { + return + } + return *v, true +} + +// ResetUpdatedAt resets all changes to the "updatedAt" field. +func (m *StationTerminalStateMutation) ResetUpdatedAt() { + m.updatedAt = nil + m.addupdatedAt = nil +} + +// Where appends a list predicates to the StationTerminalStateMutation builder. +func (m *StationTerminalStateMutation) Where(ps ...predicate.StationTerminalState) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the StationTerminalStateMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *StationTerminalStateMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.StationTerminalState, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *StationTerminalStateMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *StationTerminalStateMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (StationTerminalState). +func (m *StationTerminalStateMutation) 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 *StationTerminalStateMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.stationNo != nil { + fields = append(fields, stationterminalstate.FieldStationNo) + } + if m.powered != nil { + fields = append(fields, stationterminalstate.FieldPowered) + } + if m.loggedIn != nil { + fields = append(fields, stationterminalstate.FieldLoggedIn) + } + if m.operator != nil { + fields = append(fields, stationterminalstate.FieldOperator) + } + if m.paused != nil { + fields = append(fields, stationterminalstate.FieldPaused) + } + if m.lastHeartbeatAt != nil { + fields = append(fields, stationterminalstate.FieldLastHeartbeatAt) + } + if m.updatedAt != nil { + fields = append(fields, stationterminalstate.FieldUpdatedAt) + } + 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 *StationTerminalStateMutation) Field(name string) (ent.Value, bool) { + switch name { + case stationterminalstate.FieldStationNo: + return m.StationNo() + case stationterminalstate.FieldPowered: + return m.Powered() + case stationterminalstate.FieldLoggedIn: + return m.LoggedIn() + case stationterminalstate.FieldOperator: + return m.Operator() + case stationterminalstate.FieldPaused: + return m.Paused() + case stationterminalstate.FieldLastHeartbeatAt: + return m.LastHeartbeatAt() + case stationterminalstate.FieldUpdatedAt: + return m.UpdatedAt() + } + 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 *StationTerminalStateMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case stationterminalstate.FieldStationNo: + return m.OldStationNo(ctx) + case stationterminalstate.FieldPowered: + return m.OldPowered(ctx) + case stationterminalstate.FieldLoggedIn: + return m.OldLoggedIn(ctx) + case stationterminalstate.FieldOperator: + return m.OldOperator(ctx) + case stationterminalstate.FieldPaused: + return m.OldPaused(ctx) + case stationterminalstate.FieldLastHeartbeatAt: + return m.OldLastHeartbeatAt(ctx) + case stationterminalstate.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + } + return nil, fmt.Errorf("unknown StationTerminalState 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 *StationTerminalStateMutation) SetField(name string, value ent.Value) error { + switch name { + case stationterminalstate.FieldStationNo: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStationNo(v) + return nil + case stationterminalstate.FieldPowered: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPowered(v) + return nil + case stationterminalstate.FieldLoggedIn: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoggedIn(v) + return nil + case stationterminalstate.FieldOperator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOperator(v) + return nil + case stationterminalstate.FieldPaused: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPaused(v) + return nil + case stationterminalstate.FieldLastHeartbeatAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastHeartbeatAt(v) + return nil + case stationterminalstate.FieldUpdatedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown StationTerminalState field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *StationTerminalStateMutation) AddedFields() []string { + var fields []string + if m.addstationNo != nil { + fields = append(fields, stationterminalstate.FieldStationNo) + } + if m.addlastHeartbeatAt != nil { + fields = append(fields, stationterminalstate.FieldLastHeartbeatAt) + } + if m.addupdatedAt != nil { + fields = append(fields, stationterminalstate.FieldUpdatedAt) + } + 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 *StationTerminalStateMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case stationterminalstate.FieldStationNo: + return m.AddedStationNo() + case stationterminalstate.FieldLastHeartbeatAt: + return m.AddedLastHeartbeatAt() + case stationterminalstate.FieldUpdatedAt: + return m.AddedUpdatedAt() + } + 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 *StationTerminalStateMutation) AddField(name string, value ent.Value) error { + switch name { + case stationterminalstate.FieldStationNo: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStationNo(v) + return nil + case stationterminalstate.FieldLastHeartbeatAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLastHeartbeatAt(v) + return nil + case stationterminalstate.FieldUpdatedAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUpdatedAt(v) + return nil + } + return fmt.Errorf("unknown StationTerminalState numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *StationTerminalStateMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *StationTerminalStateMutation) 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 *StationTerminalStateMutation) ClearField(name string) error { + return fmt.Errorf("unknown StationTerminalState 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 *StationTerminalStateMutation) ResetField(name string) error { + switch name { + case stationterminalstate.FieldStationNo: + m.ResetStationNo() + return nil + case stationterminalstate.FieldPowered: + m.ResetPowered() + return nil + case stationterminalstate.FieldLoggedIn: + m.ResetLoggedIn() + return nil + case stationterminalstate.FieldOperator: + m.ResetOperator() + return nil + case stationterminalstate.FieldPaused: + m.ResetPaused() + return nil + case stationterminalstate.FieldLastHeartbeatAt: + m.ResetLastHeartbeatAt() + return nil + case stationterminalstate.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + } + return fmt.Errorf("unknown StationTerminalState field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *StationTerminalStateMutation) 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 *StationTerminalStateMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *StationTerminalStateMutation) 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 *StationTerminalStateMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *StationTerminalStateMutation) 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 *StationTerminalStateMutation) 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 *StationTerminalStateMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown StationTerminalState 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 *StationTerminalStateMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown StationTerminalState edge %s", name) +} + // StepCriterionMutation represents an operation that mutates the StepCriterion nodes in the graph. type StepCriterionMutation struct { config diff --git a/bj_power_mes/ent/predicate/predicate.go b/bj_power_mes/ent/predicate/predicate.go index 622dd87..419bd97 100644 --- a/bj_power_mes/ent/predicate/predicate.go +++ b/bj_power_mes/ent/predicate/predicate.go @@ -102,6 +102,12 @@ type StationShift func(*sql.Selector) // StationState is the predicate function for stationstate builders. type StationState func(*sql.Selector) +// StationTerminalEvent is the predicate function for stationterminalevent builders. +type StationTerminalEvent func(*sql.Selector) + +// StationTerminalState is the predicate function for stationterminalstate builders. +type StationTerminalState func(*sql.Selector) + // StepCriterion is the predicate function for stepcriterion builders. type StepCriterion func(*sql.Selector) diff --git a/bj_power_mes/ent/runtime.go b/bj_power_mes/ent/runtime.go index fad3d30..bd42fdb 100644 --- a/bj_power_mes/ent/runtime.go +++ b/bj_power_mes/ent/runtime.go @@ -35,6 +35,8 @@ import ( "bj_power_mes/ent/station" "bj_power_mes/ent/stationshift" "bj_power_mes/ent/stationstate" + "bj_power_mes/ent/stationterminalevent" + "bj_power_mes/ent/stationterminalstate" "bj_power_mes/ent/stepcriterion" "bj_power_mes/ent/stepdata" "bj_power_mes/ent/stepsignrecord" @@ -633,18 +635,22 @@ func init() { dailyplan.DefaultStatus = dailyplanDescStatus.Default.(string) // dailyplan.StatusValidator is a validator for the "status" field. It is called by the builders before save. dailyplan.StatusValidator = dailyplanDescStatus.Validators[0].(func(string) error) + // dailyplanDescDiscarded is the schema descriptor for discarded field. + dailyplanDescDiscarded := dailyplanFields[7].Descriptor() + // dailyplan.DefaultDiscarded holds the default value on creation for the discarded field. + dailyplan.DefaultDiscarded = dailyplanDescDiscarded.Default.(bool) // dailyplanDescOperator is the schema descriptor for operator field. - dailyplanDescOperator := dailyplanFields[7].Descriptor() + dailyplanDescOperator := dailyplanFields[8].Descriptor() // dailyplan.DefaultOperator holds the default value on creation for the operator field. dailyplan.DefaultOperator = dailyplanDescOperator.Default.(string) // dailyplan.OperatorValidator is a validator for the "operator" field. It is called by the builders before save. dailyplan.OperatorValidator = dailyplanDescOperator.Validators[0].(func(string) error) // dailyplanDescCreatedAt is the schema descriptor for createdAt field. - dailyplanDescCreatedAt := dailyplanFields[8].Descriptor() + dailyplanDescCreatedAt := dailyplanFields[9].Descriptor() // dailyplan.DefaultCreatedAt holds the default value on creation for the createdAt field. dailyplan.DefaultCreatedAt = dailyplanDescCreatedAt.Default.(func() time.Time) // dailyplanDescUpdatedAt is the schema descriptor for updatedAt field. - dailyplanDescUpdatedAt := dailyplanFields[9].Descriptor() + dailyplanDescUpdatedAt := dailyplanFields[10].Descriptor() // dailyplan.DefaultUpdatedAt holds the default value on creation for the updatedAt field. dailyplan.DefaultUpdatedAt = dailyplanDescUpdatedAt.Default.(func() time.Time) // dailyplan.UpdateDefaultUpdatedAt holds the default value on update for the updatedAt field. @@ -967,36 +973,14 @@ func init() { lossledger.DefaultWorkOrderNo = lossledgerDescWorkOrderNo.Default.(string) // lossledger.WorkOrderNoValidator is a validator for the "workOrderNo" field. It is called by the builders before save. lossledger.WorkOrderNoValidator = lossledgerDescWorkOrderNo.Validators[0].(func(string) error) - // lossledgerDescStatus is the schema descriptor for status field. - lossledgerDescStatus := lossledgerFields[9].Descriptor() - // lossledger.DefaultStatus holds the default value on creation for the status field. - lossledger.DefaultStatus = lossledgerDescStatus.Default.(string) - // lossledger.StatusValidator is a validator for the "status" field. It is called by the builders before save. - lossledger.StatusValidator = lossledgerDescStatus.Validators[0].(func(string) error) - // lossledgerDescComment is the schema descriptor for comment field. - lossledgerDescComment := lossledgerFields[10].Descriptor() - // lossledger.DefaultComment holds the default value on creation for the comment field. - lossledger.DefaultComment = lossledgerDescComment.Default.(string) - // lossledger.CommentValidator is a validator for the "comment" field. It is called by the builders before save. - lossledger.CommentValidator = lossledgerDescComment.Validators[0].(func(string) error) - // lossledgerDescCommenter is the schema descriptor for commenter field. - lossledgerDescCommenter := lossledgerFields[11].Descriptor() - // lossledger.DefaultCommenter holds the default value on creation for the commenter field. - lossledger.DefaultCommenter = lossledgerDescCommenter.Default.(string) - // lossledger.CommenterValidator is a validator for the "commenter" field. It is called by the builders before save. - lossledger.CommenterValidator = lossledgerDescCommenter.Validators[0].(func(string) error) - // lossledgerDescCommentedAt is the schema descriptor for commentedAt field. - lossledgerDescCommentedAt := lossledgerFields[12].Descriptor() - // lossledger.DefaultCommentedAt holds the default value on creation for the commentedAt field. - lossledger.DefaultCommentedAt = lossledgerDescCommentedAt.Default.(int64) // lossledgerDescOperator is the schema descriptor for operator field. - lossledgerDescOperator := lossledgerFields[13].Descriptor() + lossledgerDescOperator := lossledgerFields[9].Descriptor() // lossledger.DefaultOperator holds the default value on creation for the operator field. lossledger.DefaultOperator = lossledgerDescOperator.Default.(string) // lossledger.OperatorValidator is a validator for the "operator" field. It is called by the builders before save. lossledger.OperatorValidator = lossledgerDescOperator.Validators[0].(func(string) error) // lossledgerDescCreatedAt is the schema descriptor for createdAt field. - lossledgerDescCreatedAt := lossledgerFields[14].Descriptor() + lossledgerDescCreatedAt := lossledgerFields[10].Descriptor() // lossledger.DefaultCreatedAt holds the default value on creation for the createdAt field. lossledger.DefaultCreatedAt = lossledgerDescCreatedAt.Default.(func() time.Time) materialFields := schema.Material{}.Fields() @@ -1873,6 +1857,72 @@ func init() { stationstateDescID := stationstateFields[0].Descriptor() // stationstate.IDValidator is a validator for the "id" field. It is called by the builders before save. stationstate.IDValidator = stationstateDescID.Validators[0].(func(int) error) + stationterminaleventFields := schema.StationTerminalEvent{}.Fields() + _ = stationterminaleventFields + // stationterminaleventDescEvent is the schema descriptor for event field. + stationterminaleventDescEvent := stationterminaleventFields[2].Descriptor() + // stationterminalevent.EventValidator is a validator for the "event" field. It is called by the builders before save. + stationterminalevent.EventValidator = stationterminaleventDescEvent.Validators[0].(func(string) error) + // stationterminaleventDescLoggedIn is the schema descriptor for loggedIn field. + stationterminaleventDescLoggedIn := stationterminaleventFields[3].Descriptor() + // stationterminalevent.DefaultLoggedIn holds the default value on creation for the loggedIn field. + stationterminalevent.DefaultLoggedIn = stationterminaleventDescLoggedIn.Default.(bool) + // stationterminaleventDescPowered is the schema descriptor for powered field. + stationterminaleventDescPowered := stationterminaleventFields[4].Descriptor() + // stationterminalevent.DefaultPowered holds the default value on creation for the powered field. + stationterminalevent.DefaultPowered = stationterminaleventDescPowered.Default.(bool) + // stationterminaleventDescOperator is the schema descriptor for operator field. + stationterminaleventDescOperator := stationterminaleventFields[5].Descriptor() + // stationterminalevent.DefaultOperator holds the default value on creation for the operator field. + stationterminalevent.DefaultOperator = stationterminaleventDescOperator.Default.(string) + // stationterminalevent.OperatorValidator is a validator for the "operator" field. It is called by the builders before save. + stationterminalevent.OperatorValidator = stationterminaleventDescOperator.Validators[0].(func(string) error) + // stationterminaleventDescDetail is the schema descriptor for detail field. + stationterminaleventDescDetail := stationterminaleventFields[6].Descriptor() + // stationterminalevent.DefaultDetail holds the default value on creation for the detail field. + stationterminalevent.DefaultDetail = stationterminaleventDescDetail.Default.(string) + // stationterminalevent.DetailValidator is a validator for the "detail" field. It is called by the builders before save. + stationterminalevent.DetailValidator = stationterminaleventDescDetail.Validators[0].(func(string) error) + // stationterminaleventDescCreatedAt is the schema descriptor for createdAt field. + stationterminaleventDescCreatedAt := stationterminaleventFields[7].Descriptor() + // stationterminalevent.DefaultCreatedAt holds the default value on creation for the createdAt field. + stationterminalevent.DefaultCreatedAt = stationterminaleventDescCreatedAt.Default.(int64) + // stationterminaleventDescID is the schema descriptor for id field. + stationterminaleventDescID := stationterminaleventFields[0].Descriptor() + // stationterminalevent.IDValidator is a validator for the "id" field. It is called by the builders before save. + stationterminalevent.IDValidator = stationterminaleventDescID.Validators[0].(func(int) error) + stationterminalstateFields := schema.StationTerminalState{}.Fields() + _ = stationterminalstateFields + // stationterminalstateDescPowered is the schema descriptor for powered field. + stationterminalstateDescPowered := stationterminalstateFields[2].Descriptor() + // stationterminalstate.DefaultPowered holds the default value on creation for the powered field. + stationterminalstate.DefaultPowered = stationterminalstateDescPowered.Default.(bool) + // stationterminalstateDescLoggedIn is the schema descriptor for loggedIn field. + stationterminalstateDescLoggedIn := stationterminalstateFields[3].Descriptor() + // stationterminalstate.DefaultLoggedIn holds the default value on creation for the loggedIn field. + stationterminalstate.DefaultLoggedIn = stationterminalstateDescLoggedIn.Default.(bool) + // stationterminalstateDescOperator is the schema descriptor for operator field. + stationterminalstateDescOperator := stationterminalstateFields[4].Descriptor() + // stationterminalstate.DefaultOperator holds the default value on creation for the operator field. + stationterminalstate.DefaultOperator = stationterminalstateDescOperator.Default.(string) + // stationterminalstate.OperatorValidator is a validator for the "operator" field. It is called by the builders before save. + stationterminalstate.OperatorValidator = stationterminalstateDescOperator.Validators[0].(func(string) error) + // stationterminalstateDescPaused is the schema descriptor for paused field. + stationterminalstateDescPaused := stationterminalstateFields[5].Descriptor() + // stationterminalstate.DefaultPaused holds the default value on creation for the paused field. + stationterminalstate.DefaultPaused = stationterminalstateDescPaused.Default.(bool) + // stationterminalstateDescLastHeartbeatAt is the schema descriptor for lastHeartbeatAt field. + stationterminalstateDescLastHeartbeatAt := stationterminalstateFields[6].Descriptor() + // stationterminalstate.DefaultLastHeartbeatAt holds the default value on creation for the lastHeartbeatAt field. + stationterminalstate.DefaultLastHeartbeatAt = stationterminalstateDescLastHeartbeatAt.Default.(int64) + // stationterminalstateDescUpdatedAt is the schema descriptor for updatedAt field. + stationterminalstateDescUpdatedAt := stationterminalstateFields[7].Descriptor() + // stationterminalstate.DefaultUpdatedAt holds the default value on creation for the updatedAt field. + stationterminalstate.DefaultUpdatedAt = stationterminalstateDescUpdatedAt.Default.(int64) + // stationterminalstateDescID is the schema descriptor for id field. + stationterminalstateDescID := stationterminalstateFields[0].Descriptor() + // stationterminalstate.IDValidator is a validator for the "id" field. It is called by the builders before save. + stationterminalstate.IDValidator = stationterminalstateDescID.Validators[0].(func(int) error) stepcriterionFields := schema.StepCriterion{}.Fields() _ = stepcriterionFields // stepcriterionDescName is the schema descriptor for name field. diff --git a/bj_power_mes/ent/stationterminalevent.go b/bj_power_mes/ent/stationterminalevent.go new file mode 100644 index 0000000..a7250d6 --- /dev/null +++ b/bj_power_mes/ent/stationterminalevent.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/stationterminalevent" + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// StationTerminalEvent 工位终端状态变化流水(只增)。 +type StationTerminalEvent struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // 工位号 + StationNo int `json:"stationNo,omitempty"` + // 事件:stream_on/stream_off/login/logout/pause/resume/heartbeat + Event string `json:"event,omitempty"` + // 事件后登录态 + LoggedIn bool `json:"loggedIn,omitempty"` + // 事件后开机态 + Powered bool `json:"powered,omitempty"` + // 操作人 + Operator string `json:"operator,omitempty"` + // 补充说明 + Detail string `json:"detail,omitempty"` + // 事件时间 unix秒 + CreatedAt int64 `json:"createdAt,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*StationTerminalEvent) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case stationterminalevent.FieldLoggedIn, stationterminalevent.FieldPowered: + values[i] = new(sql.NullBool) + case stationterminalevent.FieldID, stationterminalevent.FieldStationNo, stationterminalevent.FieldCreatedAt: + values[i] = new(sql.NullInt64) + case stationterminalevent.FieldEvent, stationterminalevent.FieldOperator, stationterminalevent.FieldDetail: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the StationTerminalEvent fields. +func (_m *StationTerminalEvent) 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 stationterminalevent.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 stationterminalevent.FieldStationNo: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field stationNo", values[i]) + } else if value.Valid { + _m.StationNo = int(value.Int64) + } + case stationterminalevent.FieldEvent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field event", values[i]) + } else if value.Valid { + _m.Event = value.String + } + case stationterminalevent.FieldLoggedIn: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field loggedIn", values[i]) + } else if value.Valid { + _m.LoggedIn = value.Bool + } + case stationterminalevent.FieldPowered: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field powered", values[i]) + } else if value.Valid { + _m.Powered = value.Bool + } + case stationterminalevent.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 stationterminalevent.FieldDetail: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field detail", values[i]) + } else if value.Valid { + _m.Detail = value.String + } + case stationterminalevent.FieldCreatedAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field createdAt", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the StationTerminalEvent. +// This includes values selected through modifiers, order, etc. +func (_m *StationTerminalEvent) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this StationTerminalEvent. +// Note that you need to call StationTerminalEvent.Unwrap() before calling this method if this StationTerminalEvent +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *StationTerminalEvent) Update() *StationTerminalEventUpdateOne { + return NewStationTerminalEventClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the StationTerminalEvent 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 *StationTerminalEvent) Unwrap() *StationTerminalEvent { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: StationTerminalEvent is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *StationTerminalEvent) String() string { + var builder strings.Builder + builder.WriteString("StationTerminalEvent(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("stationNo=") + builder.WriteString(fmt.Sprintf("%v", _m.StationNo)) + builder.WriteString(", ") + builder.WriteString("event=") + builder.WriteString(_m.Event) + builder.WriteString(", ") + builder.WriteString("loggedIn=") + builder.WriteString(fmt.Sprintf("%v", _m.LoggedIn)) + builder.WriteString(", ") + builder.WriteString("powered=") + builder.WriteString(fmt.Sprintf("%v", _m.Powered)) + builder.WriteString(", ") + builder.WriteString("operator=") + builder.WriteString(_m.Operator) + builder.WriteString(", ") + builder.WriteString("detail=") + builder.WriteString(_m.Detail) + builder.WriteString(", ") + builder.WriteString("createdAt=") + builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt)) + builder.WriteByte(')') + return builder.String() +} + +// StationTerminalEvents is a parsable slice of StationTerminalEvent. +type StationTerminalEvents []*StationTerminalEvent diff --git a/bj_power_mes/ent/stationterminalevent/stationterminalevent.go b/bj_power_mes/ent/stationterminalevent/stationterminalevent.go new file mode 100644 index 0000000..5c27bfa --- /dev/null +++ b/bj_power_mes/ent/stationterminalevent/stationterminalevent.go @@ -0,0 +1,116 @@ +// Code generated by ent, DO NOT EDIT. + +package stationterminalevent + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the stationterminalevent type in the database. + Label = "station_terminal_event" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldStationNo holds the string denoting the stationno field in the database. + FieldStationNo = "station_no" + // FieldEvent holds the string denoting the event field in the database. + FieldEvent = "event" + // FieldLoggedIn holds the string denoting the loggedin field in the database. + FieldLoggedIn = "logged_in" + // FieldPowered holds the string denoting the powered field in the database. + FieldPowered = "powered" + // FieldOperator holds the string denoting the operator field in the database. + FieldOperator = "operator" + // FieldDetail holds the string denoting the detail field in the database. + FieldDetail = "detail" + // FieldCreatedAt holds the string denoting the createdat field in the database. + FieldCreatedAt = "created_at" + // Table holds the table name of the stationterminalevent in the database. + Table = "station_terminal_event" +) + +// Columns holds all SQL columns for stationterminalevent fields. +var Columns = []string{ + FieldID, + FieldStationNo, + FieldEvent, + FieldLoggedIn, + FieldPowered, + FieldOperator, + FieldDetail, + 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 ( + // EventValidator is a validator for the "event" field. It is called by the builders before save. + EventValidator func(string) error + // DefaultLoggedIn holds the default value on creation for the "loggedIn" field. + DefaultLoggedIn bool + // DefaultPowered holds the default value on creation for the "powered" field. + DefaultPowered bool + // 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 + // DefaultDetail holds the default value on creation for the "detail" field. + DefaultDetail string + // DetailValidator is a validator for the "detail" field. It is called by the builders before save. + DetailValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "createdAt" field. + DefaultCreatedAt int64 + // 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 StationTerminalEvent 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() +} + +// ByStationNo orders the results by the stationNo field. +func ByStationNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStationNo, opts...).ToFunc() +} + +// ByEvent orders the results by the event field. +func ByEvent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEvent, opts...).ToFunc() +} + +// ByLoggedIn orders the results by the loggedIn field. +func ByLoggedIn(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoggedIn, opts...).ToFunc() +} + +// ByPowered orders the results by the powered field. +func ByPowered(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPowered, opts...).ToFunc() +} + +// ByOperator orders the results by the operator field. +func ByOperator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOperator, opts...).ToFunc() +} + +// ByDetail orders the results by the detail field. +func ByDetail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDetail, 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/stationterminalevent/where.go b/bj_power_mes/ent/stationterminalevent/where.go new file mode 100644 index 0000000..7f92a54 --- /dev/null +++ b/bj_power_mes/ent/stationterminalevent/where.go @@ -0,0 +1,399 @@ +// Code generated by ent, DO NOT EDIT. + +package stationterminalevent + +import ( + "bj_power_mes/ent/predicate" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLTE(FieldID, id)) +} + +// StationNo applies equality check predicate on the "stationNo" field. It's identical to StationNoEQ. +func StationNo(v int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldStationNo, v)) +} + +// Event applies equality check predicate on the "event" field. It's identical to EventEQ. +func Event(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldEvent, v)) +} + +// LoggedIn applies equality check predicate on the "loggedIn" field. It's identical to LoggedInEQ. +func LoggedIn(v bool) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldLoggedIn, v)) +} + +// Powered applies equality check predicate on the "powered" field. It's identical to PoweredEQ. +func Powered(v bool) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldPowered, v)) +} + +// Operator applies equality check predicate on the "operator" field. It's identical to OperatorEQ. +func Operator(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldOperator, v)) +} + +// Detail applies equality check predicate on the "detail" field. It's identical to DetailEQ. +func Detail(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldDetail, v)) +} + +// CreatedAt applies equality check predicate on the "createdAt" field. It's identical to CreatedAtEQ. +func CreatedAt(v int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldCreatedAt, v)) +} + +// StationNoEQ applies the EQ predicate on the "stationNo" field. +func StationNoEQ(v int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldStationNo, v)) +} + +// StationNoNEQ applies the NEQ predicate on the "stationNo" field. +func StationNoNEQ(v int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldStationNo, v)) +} + +// StationNoIn applies the In predicate on the "stationNo" field. +func StationNoIn(vs ...int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldIn(FieldStationNo, vs...)) +} + +// StationNoNotIn applies the NotIn predicate on the "stationNo" field. +func StationNoNotIn(vs ...int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNotIn(FieldStationNo, vs...)) +} + +// StationNoGT applies the GT predicate on the "stationNo" field. +func StationNoGT(v int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGT(FieldStationNo, v)) +} + +// StationNoGTE applies the GTE predicate on the "stationNo" field. +func StationNoGTE(v int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGTE(FieldStationNo, v)) +} + +// StationNoLT applies the LT predicate on the "stationNo" field. +func StationNoLT(v int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLT(FieldStationNo, v)) +} + +// StationNoLTE applies the LTE predicate on the "stationNo" field. +func StationNoLTE(v int) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLTE(FieldStationNo, v)) +} + +// EventEQ applies the EQ predicate on the "event" field. +func EventEQ(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldEvent, v)) +} + +// EventNEQ applies the NEQ predicate on the "event" field. +func EventNEQ(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldEvent, v)) +} + +// EventIn applies the In predicate on the "event" field. +func EventIn(vs ...string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldIn(FieldEvent, vs...)) +} + +// EventNotIn applies the NotIn predicate on the "event" field. +func EventNotIn(vs ...string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNotIn(FieldEvent, vs...)) +} + +// EventGT applies the GT predicate on the "event" field. +func EventGT(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGT(FieldEvent, v)) +} + +// EventGTE applies the GTE predicate on the "event" field. +func EventGTE(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGTE(FieldEvent, v)) +} + +// EventLT applies the LT predicate on the "event" field. +func EventLT(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLT(FieldEvent, v)) +} + +// EventLTE applies the LTE predicate on the "event" field. +func EventLTE(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLTE(FieldEvent, v)) +} + +// EventContains applies the Contains predicate on the "event" field. +func EventContains(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldContains(FieldEvent, v)) +} + +// EventHasPrefix applies the HasPrefix predicate on the "event" field. +func EventHasPrefix(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldHasPrefix(FieldEvent, v)) +} + +// EventHasSuffix applies the HasSuffix predicate on the "event" field. +func EventHasSuffix(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldHasSuffix(FieldEvent, v)) +} + +// EventEqualFold applies the EqualFold predicate on the "event" field. +func EventEqualFold(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEqualFold(FieldEvent, v)) +} + +// EventContainsFold applies the ContainsFold predicate on the "event" field. +func EventContainsFold(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldContainsFold(FieldEvent, v)) +} + +// LoggedInEQ applies the EQ predicate on the "loggedIn" field. +func LoggedInEQ(v bool) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldLoggedIn, v)) +} + +// LoggedInNEQ applies the NEQ predicate on the "loggedIn" field. +func LoggedInNEQ(v bool) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldLoggedIn, v)) +} + +// PoweredEQ applies the EQ predicate on the "powered" field. +func PoweredEQ(v bool) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldPowered, v)) +} + +// PoweredNEQ applies the NEQ predicate on the "powered" field. +func PoweredNEQ(v bool) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldPowered, v)) +} + +// OperatorEQ applies the EQ predicate on the "operator" field. +func OperatorEQ(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldOperator, v)) +} + +// OperatorNEQ applies the NEQ predicate on the "operator" field. +func OperatorNEQ(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldOperator, v)) +} + +// OperatorIn applies the In predicate on the "operator" field. +func OperatorIn(vs ...string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldIn(FieldOperator, vs...)) +} + +// OperatorNotIn applies the NotIn predicate on the "operator" field. +func OperatorNotIn(vs ...string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNotIn(FieldOperator, vs...)) +} + +// OperatorGT applies the GT predicate on the "operator" field. +func OperatorGT(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGT(FieldOperator, v)) +} + +// OperatorGTE applies the GTE predicate on the "operator" field. +func OperatorGTE(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGTE(FieldOperator, v)) +} + +// OperatorLT applies the LT predicate on the "operator" field. +func OperatorLT(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLT(FieldOperator, v)) +} + +// OperatorLTE applies the LTE predicate on the "operator" field. +func OperatorLTE(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLTE(FieldOperator, v)) +} + +// OperatorContains applies the Contains predicate on the "operator" field. +func OperatorContains(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldContains(FieldOperator, v)) +} + +// OperatorHasPrefix applies the HasPrefix predicate on the "operator" field. +func OperatorHasPrefix(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldHasPrefix(FieldOperator, v)) +} + +// OperatorHasSuffix applies the HasSuffix predicate on the "operator" field. +func OperatorHasSuffix(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldHasSuffix(FieldOperator, v)) +} + +// OperatorEqualFold applies the EqualFold predicate on the "operator" field. +func OperatorEqualFold(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEqualFold(FieldOperator, v)) +} + +// OperatorContainsFold applies the ContainsFold predicate on the "operator" field. +func OperatorContainsFold(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldContainsFold(FieldOperator, v)) +} + +// DetailEQ applies the EQ predicate on the "detail" field. +func DetailEQ(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldDetail, v)) +} + +// DetailNEQ applies the NEQ predicate on the "detail" field. +func DetailNEQ(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldDetail, v)) +} + +// DetailIn applies the In predicate on the "detail" field. +func DetailIn(vs ...string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldIn(FieldDetail, vs...)) +} + +// DetailNotIn applies the NotIn predicate on the "detail" field. +func DetailNotIn(vs ...string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNotIn(FieldDetail, vs...)) +} + +// DetailGT applies the GT predicate on the "detail" field. +func DetailGT(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGT(FieldDetail, v)) +} + +// DetailGTE applies the GTE predicate on the "detail" field. +func DetailGTE(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGTE(FieldDetail, v)) +} + +// DetailLT applies the LT predicate on the "detail" field. +func DetailLT(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLT(FieldDetail, v)) +} + +// DetailLTE applies the LTE predicate on the "detail" field. +func DetailLTE(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLTE(FieldDetail, v)) +} + +// DetailContains applies the Contains predicate on the "detail" field. +func DetailContains(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldContains(FieldDetail, v)) +} + +// DetailHasPrefix applies the HasPrefix predicate on the "detail" field. +func DetailHasPrefix(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldHasPrefix(FieldDetail, v)) +} + +// DetailHasSuffix applies the HasSuffix predicate on the "detail" field. +func DetailHasSuffix(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldHasSuffix(FieldDetail, v)) +} + +// DetailEqualFold applies the EqualFold predicate on the "detail" field. +func DetailEqualFold(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEqualFold(FieldDetail, v)) +} + +// DetailContainsFold applies the ContainsFold predicate on the "detail" field. +func DetailContainsFold(v string) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldContainsFold(FieldDetail, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "createdAt" field. +func CreatedAtEQ(v int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "createdAt" field. +func CreatedAtNEQ(v int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "createdAt" field. +func CreatedAtIn(vs ...int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "createdAt" field. +func CreatedAtNotIn(vs ...int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "createdAt" field. +func CreatedAtGT(v int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "createdAt" field. +func CreatedAtGTE(v int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "createdAt" field. +func CreatedAtLT(v int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "createdAt" field. +func CreatedAtLTE(v int64) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.FieldLTE(FieldCreatedAt, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.StationTerminalEvent) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.StationTerminalEvent) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.StationTerminalEvent) predicate.StationTerminalEvent { + return predicate.StationTerminalEvent(sql.NotPredicates(p)) +} diff --git a/bj_power_mes/ent/stationterminalevent_create.go b/bj_power_mes/ent/stationterminalevent_create.go new file mode 100644 index 0000000..e629096 --- /dev/null +++ b/bj_power_mes/ent/stationterminalevent_create.go @@ -0,0 +1,359 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/stationterminalevent" + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// StationTerminalEventCreate is the builder for creating a StationTerminalEvent entity. +type StationTerminalEventCreate struct { + config + mutation *StationTerminalEventMutation + hooks []Hook +} + +// SetStationNo sets the "stationNo" field. +func (_c *StationTerminalEventCreate) SetStationNo(v int) *StationTerminalEventCreate { + _c.mutation.SetStationNo(v) + return _c +} + +// SetEvent sets the "event" field. +func (_c *StationTerminalEventCreate) SetEvent(v string) *StationTerminalEventCreate { + _c.mutation.SetEvent(v) + return _c +} + +// SetLoggedIn sets the "loggedIn" field. +func (_c *StationTerminalEventCreate) SetLoggedIn(v bool) *StationTerminalEventCreate { + _c.mutation.SetLoggedIn(v) + return _c +} + +// SetNillableLoggedIn sets the "loggedIn" field if the given value is not nil. +func (_c *StationTerminalEventCreate) SetNillableLoggedIn(v *bool) *StationTerminalEventCreate { + if v != nil { + _c.SetLoggedIn(*v) + } + return _c +} + +// SetPowered sets the "powered" field. +func (_c *StationTerminalEventCreate) SetPowered(v bool) *StationTerminalEventCreate { + _c.mutation.SetPowered(v) + return _c +} + +// SetNillablePowered sets the "powered" field if the given value is not nil. +func (_c *StationTerminalEventCreate) SetNillablePowered(v *bool) *StationTerminalEventCreate { + if v != nil { + _c.SetPowered(*v) + } + return _c +} + +// SetOperator sets the "operator" field. +func (_c *StationTerminalEventCreate) SetOperator(v string) *StationTerminalEventCreate { + _c.mutation.SetOperator(v) + return _c +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_c *StationTerminalEventCreate) SetNillableOperator(v *string) *StationTerminalEventCreate { + if v != nil { + _c.SetOperator(*v) + } + return _c +} + +// SetDetail sets the "detail" field. +func (_c *StationTerminalEventCreate) SetDetail(v string) *StationTerminalEventCreate { + _c.mutation.SetDetail(v) + return _c +} + +// SetNillableDetail sets the "detail" field if the given value is not nil. +func (_c *StationTerminalEventCreate) SetNillableDetail(v *string) *StationTerminalEventCreate { + if v != nil { + _c.SetDetail(*v) + } + return _c +} + +// SetCreatedAt sets the "createdAt" field. +func (_c *StationTerminalEventCreate) SetCreatedAt(v int64) *StationTerminalEventCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil. +func (_c *StationTerminalEventCreate) SetNillableCreatedAt(v *int64) *StationTerminalEventCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *StationTerminalEventCreate) SetID(v int) *StationTerminalEventCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the StationTerminalEventMutation object of the builder. +func (_c *StationTerminalEventCreate) Mutation() *StationTerminalEventMutation { + return _c.mutation +} + +// Save creates the StationTerminalEvent in the database. +func (_c *StationTerminalEventCreate) Save(ctx context.Context) (*StationTerminalEvent, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *StationTerminalEventCreate) SaveX(ctx context.Context) *StationTerminalEvent { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *StationTerminalEventCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *StationTerminalEventCreate) 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 *StationTerminalEventCreate) defaults() { + if _, ok := _c.mutation.LoggedIn(); !ok { + v := stationterminalevent.DefaultLoggedIn + _c.mutation.SetLoggedIn(v) + } + if _, ok := _c.mutation.Powered(); !ok { + v := stationterminalevent.DefaultPowered + _c.mutation.SetPowered(v) + } + if _, ok := _c.mutation.Operator(); !ok { + v := stationterminalevent.DefaultOperator + _c.mutation.SetOperator(v) + } + if _, ok := _c.mutation.Detail(); !ok { + v := stationterminalevent.DefaultDetail + _c.mutation.SetDetail(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := stationterminalevent.DefaultCreatedAt + _c.mutation.SetCreatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *StationTerminalEventCreate) check() error { + if _, ok := _c.mutation.StationNo(); !ok { + return &ValidationError{Name: "stationNo", err: errors.New(`ent: missing required field "StationTerminalEvent.stationNo"`)} + } + if _, ok := _c.mutation.Event(); !ok { + return &ValidationError{Name: "event", err: errors.New(`ent: missing required field "StationTerminalEvent.event"`)} + } + if v, ok := _c.mutation.Event(); ok { + if err := stationterminalevent.EventValidator(v); err != nil { + return &ValidationError{Name: "event", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.event": %w`, err)} + } + } + if _, ok := _c.mutation.LoggedIn(); !ok { + return &ValidationError{Name: "loggedIn", err: errors.New(`ent: missing required field "StationTerminalEvent.loggedIn"`)} + } + if _, ok := _c.mutation.Powered(); !ok { + return &ValidationError{Name: "powered", err: errors.New(`ent: missing required field "StationTerminalEvent.powered"`)} + } + if _, ok := _c.mutation.Operator(); !ok { + return &ValidationError{Name: "operator", err: errors.New(`ent: missing required field "StationTerminalEvent.operator"`)} + } + if v, ok := _c.mutation.Operator(); ok { + if err := stationterminalevent.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.operator": %w`, err)} + } + } + if _, ok := _c.mutation.Detail(); !ok { + return &ValidationError{Name: "detail", err: errors.New(`ent: missing required field "StationTerminalEvent.detail"`)} + } + if v, ok := _c.mutation.Detail(); ok { + if err := stationterminalevent.DetailValidator(v); err != nil { + return &ValidationError{Name: "detail", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.detail": %w`, err)} + } + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "StationTerminalEvent.createdAt"`)} + } + if v, ok := _c.mutation.ID(); ok { + if err := stationterminalevent.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.id": %w`, err)} + } + } + return nil +} + +func (_c *StationTerminalEventCreate) sqlSave(ctx context.Context) (*StationTerminalEvent, 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 *StationTerminalEventCreate) createSpec() (*StationTerminalEvent, *sqlgraph.CreateSpec) { + var ( + _node = &StationTerminalEvent{config: _c.config} + _spec = sqlgraph.NewCreateSpec(stationterminalevent.Table, sqlgraph.NewFieldSpec(stationterminalevent.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(stationterminalevent.FieldStationNo, field.TypeInt, value) + _node.StationNo = value + } + if value, ok := _c.mutation.Event(); ok { + _spec.SetField(stationterminalevent.FieldEvent, field.TypeString, value) + _node.Event = value + } + if value, ok := _c.mutation.LoggedIn(); ok { + _spec.SetField(stationterminalevent.FieldLoggedIn, field.TypeBool, value) + _node.LoggedIn = value + } + if value, ok := _c.mutation.Powered(); ok { + _spec.SetField(stationterminalevent.FieldPowered, field.TypeBool, value) + _node.Powered = value + } + if value, ok := _c.mutation.Operator(); ok { + _spec.SetField(stationterminalevent.FieldOperator, field.TypeString, value) + _node.Operator = value + } + if value, ok := _c.mutation.Detail(); ok { + _spec.SetField(stationterminalevent.FieldDetail, field.TypeString, value) + _node.Detail = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(stationterminalevent.FieldCreatedAt, field.TypeInt64, value) + _node.CreatedAt = value + } + return _node, _spec +} + +// StationTerminalEventCreateBulk is the builder for creating many StationTerminalEvent entities in bulk. +type StationTerminalEventCreateBulk struct { + config + err error + builders []*StationTerminalEventCreate +} + +// Save creates the StationTerminalEvent entities in the database. +func (_c *StationTerminalEventCreateBulk) Save(ctx context.Context) ([]*StationTerminalEvent, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*StationTerminalEvent, 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.(*StationTerminalEventMutation) + 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 *StationTerminalEventCreateBulk) SaveX(ctx context.Context) []*StationTerminalEvent { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *StationTerminalEventCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *StationTerminalEventCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/stationterminalevent_delete.go b/bj_power_mes/ent/stationterminalevent_delete.go new file mode 100644 index 0000000..03181b9 --- /dev/null +++ b/bj_power_mes/ent/stationterminalevent_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/stationterminalevent" + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// StationTerminalEventDelete is the builder for deleting a StationTerminalEvent entity. +type StationTerminalEventDelete struct { + config + hooks []Hook + mutation *StationTerminalEventMutation +} + +// Where appends a list predicates to the StationTerminalEventDelete builder. +func (_d *StationTerminalEventDelete) Where(ps ...predicate.StationTerminalEvent) *StationTerminalEventDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *StationTerminalEventDelete) 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 *StationTerminalEventDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *StationTerminalEventDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(stationterminalevent.Table, sqlgraph.NewFieldSpec(stationterminalevent.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 +} + +// StationTerminalEventDeleteOne is the builder for deleting a single StationTerminalEvent entity. +type StationTerminalEventDeleteOne struct { + _d *StationTerminalEventDelete +} + +// Where appends a list predicates to the StationTerminalEventDelete builder. +func (_d *StationTerminalEventDeleteOne) Where(ps ...predicate.StationTerminalEvent) *StationTerminalEventDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *StationTerminalEventDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{stationterminalevent.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *StationTerminalEventDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/stationterminalevent_query.go b/bj_power_mes/ent/stationterminalevent_query.go new file mode 100644 index 0000000..aea8d31 --- /dev/null +++ b/bj_power_mes/ent/stationterminalevent_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/stationterminalevent" + "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" +) + +// StationTerminalEventQuery is the builder for querying StationTerminalEvent entities. +type StationTerminalEventQuery struct { + config + ctx *QueryContext + order []stationterminalevent.OrderOption + inters []Interceptor + predicates []predicate.StationTerminalEvent + 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 StationTerminalEventQuery builder. +func (_q *StationTerminalEventQuery) Where(ps ...predicate.StationTerminalEvent) *StationTerminalEventQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *StationTerminalEventQuery) Limit(limit int) *StationTerminalEventQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *StationTerminalEventQuery) Offset(offset int) *StationTerminalEventQuery { + _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 *StationTerminalEventQuery) Unique(unique bool) *StationTerminalEventQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *StationTerminalEventQuery) Order(o ...stationterminalevent.OrderOption) *StationTerminalEventQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first StationTerminalEvent entity from the query. +// Returns a *NotFoundError when no StationTerminalEvent was found. +func (_q *StationTerminalEventQuery) First(ctx context.Context) (*StationTerminalEvent, 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{stationterminalevent.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *StationTerminalEventQuery) FirstX(ctx context.Context) *StationTerminalEvent { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first StationTerminalEvent ID from the query. +// Returns a *NotFoundError when no StationTerminalEvent ID was found. +func (_q *StationTerminalEventQuery) 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{stationterminalevent.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *StationTerminalEventQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single StationTerminalEvent entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one StationTerminalEvent entity is found. +// Returns a *NotFoundError when no StationTerminalEvent entities are found. +func (_q *StationTerminalEventQuery) Only(ctx context.Context) (*StationTerminalEvent, 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{stationterminalevent.Label} + default: + return nil, &NotSingularError{stationterminalevent.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *StationTerminalEventQuery) OnlyX(ctx context.Context) *StationTerminalEvent { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only StationTerminalEvent ID in the query. +// Returns a *NotSingularError when more than one StationTerminalEvent ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *StationTerminalEventQuery) 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{stationterminalevent.Label} + default: + err = &NotSingularError{stationterminalevent.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *StationTerminalEventQuery) 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 StationTerminalEvents. +func (_q *StationTerminalEventQuery) All(ctx context.Context) ([]*StationTerminalEvent, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*StationTerminalEvent, *StationTerminalEventQuery]() + return withInterceptors[[]*StationTerminalEvent](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *StationTerminalEventQuery) AllX(ctx context.Context) []*StationTerminalEvent { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of StationTerminalEvent IDs. +func (_q *StationTerminalEventQuery) 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(stationterminalevent.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *StationTerminalEventQuery) 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 *StationTerminalEventQuery) 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[*StationTerminalEventQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *StationTerminalEventQuery) 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 *StationTerminalEventQuery) 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 *StationTerminalEventQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the StationTerminalEventQuery 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 *StationTerminalEventQuery) Clone() *StationTerminalEventQuery { + if _q == nil { + return nil + } + return &StationTerminalEventQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]stationterminalevent.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.StationTerminalEvent{}, _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 { +// StationNo int `json:"stationNo,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.StationTerminalEvent.Query(). +// GroupBy(stationterminalevent.FieldStationNo). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *StationTerminalEventQuery) GroupBy(field string, fields ...string) *StationTerminalEventGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &StationTerminalEventGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = stationterminalevent.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 { +// StationNo int `json:"stationNo,omitempty"` +// } +// +// client.StationTerminalEvent.Query(). +// Select(stationterminalevent.FieldStationNo). +// Scan(ctx, &v) +func (_q *StationTerminalEventQuery) Select(fields ...string) *StationTerminalEventSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &StationTerminalEventSelect{StationTerminalEventQuery: _q} + sbuild.label = stationterminalevent.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a StationTerminalEventSelect configured with the given aggregations. +func (_q *StationTerminalEventQuery) Aggregate(fns ...AggregateFunc) *StationTerminalEventSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *StationTerminalEventQuery) 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 !stationterminalevent.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 *StationTerminalEventQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*StationTerminalEvent, error) { + var ( + nodes = []*StationTerminalEvent{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*StationTerminalEvent).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &StationTerminalEvent{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 *StationTerminalEventQuery) 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 *StationTerminalEventQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(stationterminalevent.Table, stationterminalevent.Columns, sqlgraph.NewFieldSpec(stationterminalevent.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, stationterminalevent.FieldID) + for i := range fields { + if fields[i] != stationterminalevent.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 *StationTerminalEventQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(stationterminalevent.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = stationterminalevent.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 *StationTerminalEventQuery) ForUpdate(opts ...sql.LockOption) *StationTerminalEventQuery { + 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 *StationTerminalEventQuery) ForShare(opts ...sql.LockOption) *StationTerminalEventQuery { + 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 *StationTerminalEventQuery) Modify(modifiers ...func(s *sql.Selector)) *StationTerminalEventSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// StationTerminalEventGroupBy is the group-by builder for StationTerminalEvent entities. +type StationTerminalEventGroupBy struct { + selector + build *StationTerminalEventQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *StationTerminalEventGroupBy) Aggregate(fns ...AggregateFunc) *StationTerminalEventGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *StationTerminalEventGroupBy) 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[*StationTerminalEventQuery, *StationTerminalEventGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *StationTerminalEventGroupBy) sqlScan(ctx context.Context, root *StationTerminalEventQuery, 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) +} + +// StationTerminalEventSelect is the builder for selecting fields of StationTerminalEvent entities. +type StationTerminalEventSelect struct { + *StationTerminalEventQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *StationTerminalEventSelect) Aggregate(fns ...AggregateFunc) *StationTerminalEventSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *StationTerminalEventSelect) 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[*StationTerminalEventQuery, *StationTerminalEventSelect](ctx, _s.StationTerminalEventQuery, _s, _s.inters, v) +} + +func (_s *StationTerminalEventSelect) sqlScan(ctx context.Context, root *StationTerminalEventQuery, 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 *StationTerminalEventSelect) Modify(modifiers ...func(s *sql.Selector)) *StationTerminalEventSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/bj_power_mes/ent/stationterminalevent_update.go b/bj_power_mes/ent/stationterminalevent_update.go new file mode 100644 index 0000000..5f53534 --- /dev/null +++ b/bj_power_mes/ent/stationterminalevent_update.go @@ -0,0 +1,515 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/predicate" + "bj_power_mes/ent/stationterminalevent" + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// StationTerminalEventUpdate is the builder for updating StationTerminalEvent entities. +type StationTerminalEventUpdate struct { + config + hooks []Hook + mutation *StationTerminalEventMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the StationTerminalEventUpdate builder. +func (_u *StationTerminalEventUpdate) Where(ps ...predicate.StationTerminalEvent) *StationTerminalEventUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetStationNo sets the "stationNo" field. +func (_u *StationTerminalEventUpdate) SetStationNo(v int) *StationTerminalEventUpdate { + _u.mutation.ResetStationNo() + _u.mutation.SetStationNo(v) + return _u +} + +// SetNillableStationNo sets the "stationNo" field if the given value is not nil. +func (_u *StationTerminalEventUpdate) SetNillableStationNo(v *int) *StationTerminalEventUpdate { + if v != nil { + _u.SetStationNo(*v) + } + return _u +} + +// AddStationNo adds value to the "stationNo" field. +func (_u *StationTerminalEventUpdate) AddStationNo(v int) *StationTerminalEventUpdate { + _u.mutation.AddStationNo(v) + return _u +} + +// SetEvent sets the "event" field. +func (_u *StationTerminalEventUpdate) SetEvent(v string) *StationTerminalEventUpdate { + _u.mutation.SetEvent(v) + return _u +} + +// SetNillableEvent sets the "event" field if the given value is not nil. +func (_u *StationTerminalEventUpdate) SetNillableEvent(v *string) *StationTerminalEventUpdate { + if v != nil { + _u.SetEvent(*v) + } + return _u +} + +// SetLoggedIn sets the "loggedIn" field. +func (_u *StationTerminalEventUpdate) SetLoggedIn(v bool) *StationTerminalEventUpdate { + _u.mutation.SetLoggedIn(v) + return _u +} + +// SetNillableLoggedIn sets the "loggedIn" field if the given value is not nil. +func (_u *StationTerminalEventUpdate) SetNillableLoggedIn(v *bool) *StationTerminalEventUpdate { + if v != nil { + _u.SetLoggedIn(*v) + } + return _u +} + +// SetPowered sets the "powered" field. +func (_u *StationTerminalEventUpdate) SetPowered(v bool) *StationTerminalEventUpdate { + _u.mutation.SetPowered(v) + return _u +} + +// SetNillablePowered sets the "powered" field if the given value is not nil. +func (_u *StationTerminalEventUpdate) SetNillablePowered(v *bool) *StationTerminalEventUpdate { + if v != nil { + _u.SetPowered(*v) + } + return _u +} + +// SetOperator sets the "operator" field. +func (_u *StationTerminalEventUpdate) SetOperator(v string) *StationTerminalEventUpdate { + _u.mutation.SetOperator(v) + return _u +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_u *StationTerminalEventUpdate) SetNillableOperator(v *string) *StationTerminalEventUpdate { + if v != nil { + _u.SetOperator(*v) + } + return _u +} + +// SetDetail sets the "detail" field. +func (_u *StationTerminalEventUpdate) SetDetail(v string) *StationTerminalEventUpdate { + _u.mutation.SetDetail(v) + return _u +} + +// SetNillableDetail sets the "detail" field if the given value is not nil. +func (_u *StationTerminalEventUpdate) SetNillableDetail(v *string) *StationTerminalEventUpdate { + if v != nil { + _u.SetDetail(*v) + } + return _u +} + +// SetCreatedAt sets the "createdAt" field. +func (_u *StationTerminalEventUpdate) SetCreatedAt(v int64) *StationTerminalEventUpdate { + _u.mutation.ResetCreatedAt() + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil. +func (_u *StationTerminalEventUpdate) SetNillableCreatedAt(v *int64) *StationTerminalEventUpdate { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// AddCreatedAt adds value to the "createdAt" field. +func (_u *StationTerminalEventUpdate) AddCreatedAt(v int64) *StationTerminalEventUpdate { + _u.mutation.AddCreatedAt(v) + return _u +} + +// Mutation returns the StationTerminalEventMutation object of the builder. +func (_u *StationTerminalEventUpdate) Mutation() *StationTerminalEventMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *StationTerminalEventUpdate) 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 *StationTerminalEventUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *StationTerminalEventUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *StationTerminalEventUpdate) 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 *StationTerminalEventUpdate) check() error { + if v, ok := _u.mutation.Event(); ok { + if err := stationterminalevent.EventValidator(v); err != nil { + return &ValidationError{Name: "event", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.event": %w`, err)} + } + } + if v, ok := _u.mutation.Operator(); ok { + if err := stationterminalevent.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.operator": %w`, err)} + } + } + if v, ok := _u.mutation.Detail(); ok { + if err := stationterminalevent.DetailValidator(v); err != nil { + return &ValidationError{Name: "detail", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.detail": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *StationTerminalEventUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationTerminalEventUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *StationTerminalEventUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(stationterminalevent.Table, stationterminalevent.Columns, sqlgraph.NewFieldSpec(stationterminalevent.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.StationNo(); ok { + _spec.SetField(stationterminalevent.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStationNo(); ok { + _spec.AddField(stationterminalevent.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.Event(); ok { + _spec.SetField(stationterminalevent.FieldEvent, field.TypeString, value) + } + if value, ok := _u.mutation.LoggedIn(); ok { + _spec.SetField(stationterminalevent.FieldLoggedIn, field.TypeBool, value) + } + if value, ok := _u.mutation.Powered(); ok { + _spec.SetField(stationterminalevent.FieldPowered, field.TypeBool, value) + } + if value, ok := _u.mutation.Operator(); ok { + _spec.SetField(stationterminalevent.FieldOperator, field.TypeString, value) + } + if value, ok := _u.mutation.Detail(); ok { + _spec.SetField(stationterminalevent.FieldDetail, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(stationterminalevent.FieldCreatedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedCreatedAt(); ok { + _spec.AddField(stationterminalevent.FieldCreatedAt, field.TypeInt64, value) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{stationterminalevent.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// StationTerminalEventUpdateOne is the builder for updating a single StationTerminalEvent entity. +type StationTerminalEventUpdateOne struct { + config + fields []string + hooks []Hook + mutation *StationTerminalEventMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetStationNo sets the "stationNo" field. +func (_u *StationTerminalEventUpdateOne) SetStationNo(v int) *StationTerminalEventUpdateOne { + _u.mutation.ResetStationNo() + _u.mutation.SetStationNo(v) + return _u +} + +// SetNillableStationNo sets the "stationNo" field if the given value is not nil. +func (_u *StationTerminalEventUpdateOne) SetNillableStationNo(v *int) *StationTerminalEventUpdateOne { + if v != nil { + _u.SetStationNo(*v) + } + return _u +} + +// AddStationNo adds value to the "stationNo" field. +func (_u *StationTerminalEventUpdateOne) AddStationNo(v int) *StationTerminalEventUpdateOne { + _u.mutation.AddStationNo(v) + return _u +} + +// SetEvent sets the "event" field. +func (_u *StationTerminalEventUpdateOne) SetEvent(v string) *StationTerminalEventUpdateOne { + _u.mutation.SetEvent(v) + return _u +} + +// SetNillableEvent sets the "event" field if the given value is not nil. +func (_u *StationTerminalEventUpdateOne) SetNillableEvent(v *string) *StationTerminalEventUpdateOne { + if v != nil { + _u.SetEvent(*v) + } + return _u +} + +// SetLoggedIn sets the "loggedIn" field. +func (_u *StationTerminalEventUpdateOne) SetLoggedIn(v bool) *StationTerminalEventUpdateOne { + _u.mutation.SetLoggedIn(v) + return _u +} + +// SetNillableLoggedIn sets the "loggedIn" field if the given value is not nil. +func (_u *StationTerminalEventUpdateOne) SetNillableLoggedIn(v *bool) *StationTerminalEventUpdateOne { + if v != nil { + _u.SetLoggedIn(*v) + } + return _u +} + +// SetPowered sets the "powered" field. +func (_u *StationTerminalEventUpdateOne) SetPowered(v bool) *StationTerminalEventUpdateOne { + _u.mutation.SetPowered(v) + return _u +} + +// SetNillablePowered sets the "powered" field if the given value is not nil. +func (_u *StationTerminalEventUpdateOne) SetNillablePowered(v *bool) *StationTerminalEventUpdateOne { + if v != nil { + _u.SetPowered(*v) + } + return _u +} + +// SetOperator sets the "operator" field. +func (_u *StationTerminalEventUpdateOne) SetOperator(v string) *StationTerminalEventUpdateOne { + _u.mutation.SetOperator(v) + return _u +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_u *StationTerminalEventUpdateOne) SetNillableOperator(v *string) *StationTerminalEventUpdateOne { + if v != nil { + _u.SetOperator(*v) + } + return _u +} + +// SetDetail sets the "detail" field. +func (_u *StationTerminalEventUpdateOne) SetDetail(v string) *StationTerminalEventUpdateOne { + _u.mutation.SetDetail(v) + return _u +} + +// SetNillableDetail sets the "detail" field if the given value is not nil. +func (_u *StationTerminalEventUpdateOne) SetNillableDetail(v *string) *StationTerminalEventUpdateOne { + if v != nil { + _u.SetDetail(*v) + } + return _u +} + +// SetCreatedAt sets the "createdAt" field. +func (_u *StationTerminalEventUpdateOne) SetCreatedAt(v int64) *StationTerminalEventUpdateOne { + _u.mutation.ResetCreatedAt() + _u.mutation.SetCreatedAt(v) + return _u +} + +// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil. +func (_u *StationTerminalEventUpdateOne) SetNillableCreatedAt(v *int64) *StationTerminalEventUpdateOne { + if v != nil { + _u.SetCreatedAt(*v) + } + return _u +} + +// AddCreatedAt adds value to the "createdAt" field. +func (_u *StationTerminalEventUpdateOne) AddCreatedAt(v int64) *StationTerminalEventUpdateOne { + _u.mutation.AddCreatedAt(v) + return _u +} + +// Mutation returns the StationTerminalEventMutation object of the builder. +func (_u *StationTerminalEventUpdateOne) Mutation() *StationTerminalEventMutation { + return _u.mutation +} + +// Where appends a list predicates to the StationTerminalEventUpdate builder. +func (_u *StationTerminalEventUpdateOne) Where(ps ...predicate.StationTerminalEvent) *StationTerminalEventUpdateOne { + _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 *StationTerminalEventUpdateOne) Select(field string, fields ...string) *StationTerminalEventUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated StationTerminalEvent entity. +func (_u *StationTerminalEventUpdateOne) Save(ctx context.Context) (*StationTerminalEvent, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *StationTerminalEventUpdateOne) SaveX(ctx context.Context) *StationTerminalEvent { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *StationTerminalEventUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *StationTerminalEventUpdateOne) 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 *StationTerminalEventUpdateOne) check() error { + if v, ok := _u.mutation.Event(); ok { + if err := stationterminalevent.EventValidator(v); err != nil { + return &ValidationError{Name: "event", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.event": %w`, err)} + } + } + if v, ok := _u.mutation.Operator(); ok { + if err := stationterminalevent.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.operator": %w`, err)} + } + } + if v, ok := _u.mutation.Detail(); ok { + if err := stationterminalevent.DetailValidator(v); err != nil { + return &ValidationError{Name: "detail", err: fmt.Errorf(`ent: validator failed for field "StationTerminalEvent.detail": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *StationTerminalEventUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationTerminalEventUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *StationTerminalEventUpdateOne) sqlSave(ctx context.Context) (_node *StationTerminalEvent, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(stationterminalevent.Table, stationterminalevent.Columns, sqlgraph.NewFieldSpec(stationterminalevent.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "StationTerminalEvent.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, stationterminalevent.FieldID) + for _, f := range fields { + if !stationterminalevent.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != stationterminalevent.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.StationNo(); ok { + _spec.SetField(stationterminalevent.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStationNo(); ok { + _spec.AddField(stationterminalevent.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.Event(); ok { + _spec.SetField(stationterminalevent.FieldEvent, field.TypeString, value) + } + if value, ok := _u.mutation.LoggedIn(); ok { + _spec.SetField(stationterminalevent.FieldLoggedIn, field.TypeBool, value) + } + if value, ok := _u.mutation.Powered(); ok { + _spec.SetField(stationterminalevent.FieldPowered, field.TypeBool, value) + } + if value, ok := _u.mutation.Operator(); ok { + _spec.SetField(stationterminalevent.FieldOperator, field.TypeString, value) + } + if value, ok := _u.mutation.Detail(); ok { + _spec.SetField(stationterminalevent.FieldDetail, field.TypeString, value) + } + if value, ok := _u.mutation.CreatedAt(); ok { + _spec.SetField(stationterminalevent.FieldCreatedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedCreatedAt(); ok { + _spec.AddField(stationterminalevent.FieldCreatedAt, field.TypeInt64, value) + } + _spec.AddModifiers(_u.modifiers...) + _node = &StationTerminalEvent{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{stationterminalevent.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/ent/stationterminalstate.go b/bj_power_mes/ent/stationterminalstate.go new file mode 100644 index 0000000..87973a1 --- /dev/null +++ b/bj_power_mes/ent/stationterminalstate.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/stationterminalstate" + "fmt" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// StationTerminalState 工位终端当前状态(上报镜像+心跳)。 +type StationTerminalState struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // 工位号 + StationNo int `json:"stationNo,omitempty"` + // 终端是否在线(SSE 建连 stream_on 置 true,断连 stream_off 置 false) + Powered bool `json:"powered,omitempty"` + // 该工位是否有登录会话(终端上报登录=是/退出=否) + LoggedIn bool `json:"loggedIn,omitempty"` + // 当前登录人(终端上报;无会话为空) + Operator string `json:"operator,omitempty"` + // 是否暂停接单(终端上报暂停/恢复) + Paused bool `json:"paused,omitempty"` + // 最近一次 SSE ping 心跳时间 unix秒(0=从未连接) + LastHeartbeatAt int64 `json:"lastHeartbeatAt,omitempty"` + // 状态更新时间 unix秒 + UpdatedAt int64 `json:"updatedAt,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*StationTerminalState) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case stationterminalstate.FieldPowered, stationterminalstate.FieldLoggedIn, stationterminalstate.FieldPaused: + values[i] = new(sql.NullBool) + case stationterminalstate.FieldID, stationterminalstate.FieldStationNo, stationterminalstate.FieldLastHeartbeatAt, stationterminalstate.FieldUpdatedAt: + values[i] = new(sql.NullInt64) + case stationterminalstate.FieldOperator: + values[i] = new(sql.NullString) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the StationTerminalState fields. +func (_m *StationTerminalState) 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 stationterminalstate.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 stationterminalstate.FieldStationNo: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field stationNo", values[i]) + } else if value.Valid { + _m.StationNo = int(value.Int64) + } + case stationterminalstate.FieldPowered: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field powered", values[i]) + } else if value.Valid { + _m.Powered = value.Bool + } + case stationterminalstate.FieldLoggedIn: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field loggedIn", values[i]) + } else if value.Valid { + _m.LoggedIn = value.Bool + } + case stationterminalstate.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 stationterminalstate.FieldPaused: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field paused", values[i]) + } else if value.Valid { + _m.Paused = value.Bool + } + case stationterminalstate.FieldLastHeartbeatAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field lastHeartbeatAt", values[i]) + } else if value.Valid { + _m.LastHeartbeatAt = value.Int64 + } + case stationterminalstate.FieldUpdatedAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field updatedAt", values[i]) + } else if value.Valid { + _m.UpdatedAt = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the StationTerminalState. +// This includes values selected through modifiers, order, etc. +func (_m *StationTerminalState) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this StationTerminalState. +// Note that you need to call StationTerminalState.Unwrap() before calling this method if this StationTerminalState +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *StationTerminalState) Update() *StationTerminalStateUpdateOne { + return NewStationTerminalStateClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the StationTerminalState 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 *StationTerminalState) Unwrap() *StationTerminalState { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: StationTerminalState is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *StationTerminalState) String() string { + var builder strings.Builder + builder.WriteString("StationTerminalState(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("stationNo=") + builder.WriteString(fmt.Sprintf("%v", _m.StationNo)) + builder.WriteString(", ") + builder.WriteString("powered=") + builder.WriteString(fmt.Sprintf("%v", _m.Powered)) + builder.WriteString(", ") + builder.WriteString("loggedIn=") + builder.WriteString(fmt.Sprintf("%v", _m.LoggedIn)) + builder.WriteString(", ") + builder.WriteString("operator=") + builder.WriteString(_m.Operator) + builder.WriteString(", ") + builder.WriteString("paused=") + builder.WriteString(fmt.Sprintf("%v", _m.Paused)) + builder.WriteString(", ") + builder.WriteString("lastHeartbeatAt=") + builder.WriteString(fmt.Sprintf("%v", _m.LastHeartbeatAt)) + builder.WriteString(", ") + builder.WriteString("updatedAt=") + builder.WriteString(fmt.Sprintf("%v", _m.UpdatedAt)) + builder.WriteByte(')') + return builder.String() +} + +// StationTerminalStates is a parsable slice of StationTerminalState. +type StationTerminalStates []*StationTerminalState diff --git a/bj_power_mes/ent/stationterminalstate/stationterminalstate.go b/bj_power_mes/ent/stationterminalstate/stationterminalstate.go new file mode 100644 index 0000000..cdd36e5 --- /dev/null +++ b/bj_power_mes/ent/stationterminalstate/stationterminalstate.go @@ -0,0 +1,114 @@ +// Code generated by ent, DO NOT EDIT. + +package stationterminalstate + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the stationterminalstate type in the database. + Label = "station_terminal_state" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldStationNo holds the string denoting the stationno field in the database. + FieldStationNo = "station_no" + // FieldPowered holds the string denoting the powered field in the database. + FieldPowered = "powered" + // FieldLoggedIn holds the string denoting the loggedin field in the database. + FieldLoggedIn = "logged_in" + // FieldOperator holds the string denoting the operator field in the database. + FieldOperator = "operator" + // FieldPaused holds the string denoting the paused field in the database. + FieldPaused = "paused" + // FieldLastHeartbeatAt holds the string denoting the lastheartbeatat field in the database. + FieldLastHeartbeatAt = "last_heartbeat_at" + // FieldUpdatedAt holds the string denoting the updatedat field in the database. + FieldUpdatedAt = "updated_at" + // Table holds the table name of the stationterminalstate in the database. + Table = "station_terminal_state" +) + +// Columns holds all SQL columns for stationterminalstate fields. +var Columns = []string{ + FieldID, + FieldStationNo, + FieldPowered, + FieldLoggedIn, + FieldOperator, + FieldPaused, + FieldLastHeartbeatAt, + FieldUpdatedAt, +} + +// 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 ( + // DefaultPowered holds the default value on creation for the "powered" field. + DefaultPowered bool + // DefaultLoggedIn holds the default value on creation for the "loggedIn" field. + DefaultLoggedIn bool + // 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 + // DefaultPaused holds the default value on creation for the "paused" field. + DefaultPaused bool + // DefaultLastHeartbeatAt holds the default value on creation for the "lastHeartbeatAt" field. + DefaultLastHeartbeatAt int64 + // DefaultUpdatedAt holds the default value on creation for the "updatedAt" field. + DefaultUpdatedAt int64 + // 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 StationTerminalState 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() +} + +// ByStationNo orders the results by the stationNo field. +func ByStationNo(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStationNo, opts...).ToFunc() +} + +// ByPowered orders the results by the powered field. +func ByPowered(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPowered, opts...).ToFunc() +} + +// ByLoggedIn orders the results by the loggedIn field. +func ByLoggedIn(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoggedIn, opts...).ToFunc() +} + +// ByOperator orders the results by the operator field. +func ByOperator(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOperator, opts...).ToFunc() +} + +// ByPaused orders the results by the paused field. +func ByPaused(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPaused, opts...).ToFunc() +} + +// ByLastHeartbeatAt orders the results by the lastHeartbeatAt field. +func ByLastHeartbeatAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastHeartbeatAt, opts...).ToFunc() +} + +// ByUpdatedAt orders the results by the updatedAt field. +func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() +} diff --git a/bj_power_mes/ent/stationterminalstate/where.go b/bj_power_mes/ent/stationterminalstate/where.go new file mode 100644 index 0000000..adfec8e --- /dev/null +++ b/bj_power_mes/ent/stationterminalstate/where.go @@ -0,0 +1,319 @@ +// Code generated by ent, DO NOT EDIT. + +package stationterminalstate + +import ( + "bj_power_mes/ent/predicate" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLTE(FieldID, id)) +} + +// StationNo applies equality check predicate on the "stationNo" field. It's identical to StationNoEQ. +func StationNo(v int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldStationNo, v)) +} + +// Powered applies equality check predicate on the "powered" field. It's identical to PoweredEQ. +func Powered(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldPowered, v)) +} + +// LoggedIn applies equality check predicate on the "loggedIn" field. It's identical to LoggedInEQ. +func LoggedIn(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldLoggedIn, v)) +} + +// Operator applies equality check predicate on the "operator" field. It's identical to OperatorEQ. +func Operator(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldOperator, v)) +} + +// Paused applies equality check predicate on the "paused" field. It's identical to PausedEQ. +func Paused(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldPaused, v)) +} + +// LastHeartbeatAt applies equality check predicate on the "lastHeartbeatAt" field. It's identical to LastHeartbeatAtEQ. +func LastHeartbeatAt(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldLastHeartbeatAt, v)) +} + +// UpdatedAt applies equality check predicate on the "updatedAt" field. It's identical to UpdatedAtEQ. +func UpdatedAt(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// StationNoEQ applies the EQ predicate on the "stationNo" field. +func StationNoEQ(v int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldStationNo, v)) +} + +// StationNoNEQ applies the NEQ predicate on the "stationNo" field. +func StationNoNEQ(v int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldStationNo, v)) +} + +// StationNoIn applies the In predicate on the "stationNo" field. +func StationNoIn(vs ...int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldIn(FieldStationNo, vs...)) +} + +// StationNoNotIn applies the NotIn predicate on the "stationNo" field. +func StationNoNotIn(vs ...int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNotIn(FieldStationNo, vs...)) +} + +// StationNoGT applies the GT predicate on the "stationNo" field. +func StationNoGT(v int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGT(FieldStationNo, v)) +} + +// StationNoGTE applies the GTE predicate on the "stationNo" field. +func StationNoGTE(v int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGTE(FieldStationNo, v)) +} + +// StationNoLT applies the LT predicate on the "stationNo" field. +func StationNoLT(v int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLT(FieldStationNo, v)) +} + +// StationNoLTE applies the LTE predicate on the "stationNo" field. +func StationNoLTE(v int) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLTE(FieldStationNo, v)) +} + +// PoweredEQ applies the EQ predicate on the "powered" field. +func PoweredEQ(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldPowered, v)) +} + +// PoweredNEQ applies the NEQ predicate on the "powered" field. +func PoweredNEQ(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldPowered, v)) +} + +// LoggedInEQ applies the EQ predicate on the "loggedIn" field. +func LoggedInEQ(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldLoggedIn, v)) +} + +// LoggedInNEQ applies the NEQ predicate on the "loggedIn" field. +func LoggedInNEQ(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldLoggedIn, v)) +} + +// OperatorEQ applies the EQ predicate on the "operator" field. +func OperatorEQ(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldOperator, v)) +} + +// OperatorNEQ applies the NEQ predicate on the "operator" field. +func OperatorNEQ(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldOperator, v)) +} + +// OperatorIn applies the In predicate on the "operator" field. +func OperatorIn(vs ...string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldIn(FieldOperator, vs...)) +} + +// OperatorNotIn applies the NotIn predicate on the "operator" field. +func OperatorNotIn(vs ...string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNotIn(FieldOperator, vs...)) +} + +// OperatorGT applies the GT predicate on the "operator" field. +func OperatorGT(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGT(FieldOperator, v)) +} + +// OperatorGTE applies the GTE predicate on the "operator" field. +func OperatorGTE(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGTE(FieldOperator, v)) +} + +// OperatorLT applies the LT predicate on the "operator" field. +func OperatorLT(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLT(FieldOperator, v)) +} + +// OperatorLTE applies the LTE predicate on the "operator" field. +func OperatorLTE(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLTE(FieldOperator, v)) +} + +// OperatorContains applies the Contains predicate on the "operator" field. +func OperatorContains(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldContains(FieldOperator, v)) +} + +// OperatorHasPrefix applies the HasPrefix predicate on the "operator" field. +func OperatorHasPrefix(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldHasPrefix(FieldOperator, v)) +} + +// OperatorHasSuffix applies the HasSuffix predicate on the "operator" field. +func OperatorHasSuffix(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldHasSuffix(FieldOperator, v)) +} + +// OperatorEqualFold applies the EqualFold predicate on the "operator" field. +func OperatorEqualFold(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEqualFold(FieldOperator, v)) +} + +// OperatorContainsFold applies the ContainsFold predicate on the "operator" field. +func OperatorContainsFold(v string) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldContainsFold(FieldOperator, v)) +} + +// PausedEQ applies the EQ predicate on the "paused" field. +func PausedEQ(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldPaused, v)) +} + +// PausedNEQ applies the NEQ predicate on the "paused" field. +func PausedNEQ(v bool) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldPaused, v)) +} + +// LastHeartbeatAtEQ applies the EQ predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtEQ(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldLastHeartbeatAt, v)) +} + +// LastHeartbeatAtNEQ applies the NEQ predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtNEQ(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldLastHeartbeatAt, v)) +} + +// LastHeartbeatAtIn applies the In predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtIn(vs ...int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldIn(FieldLastHeartbeatAt, vs...)) +} + +// LastHeartbeatAtNotIn applies the NotIn predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtNotIn(vs ...int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNotIn(FieldLastHeartbeatAt, vs...)) +} + +// LastHeartbeatAtGT applies the GT predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtGT(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGT(FieldLastHeartbeatAt, v)) +} + +// LastHeartbeatAtGTE applies the GTE predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtGTE(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGTE(FieldLastHeartbeatAt, v)) +} + +// LastHeartbeatAtLT applies the LT predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtLT(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLT(FieldLastHeartbeatAt, v)) +} + +// LastHeartbeatAtLTE applies the LTE predicate on the "lastHeartbeatAt" field. +func LastHeartbeatAtLTE(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLTE(FieldLastHeartbeatAt, v)) +} + +// UpdatedAtEQ applies the EQ predicate on the "updatedAt" field. +func UpdatedAtEQ(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtNEQ applies the NEQ predicate on the "updatedAt" field. +func UpdatedAtNEQ(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNEQ(FieldUpdatedAt, v)) +} + +// UpdatedAtIn applies the In predicate on the "updatedAt" field. +func UpdatedAtIn(vs ...int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtNotIn applies the NotIn predicate on the "updatedAt" field. +func UpdatedAtNotIn(vs ...int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldNotIn(FieldUpdatedAt, vs...)) +} + +// UpdatedAtGT applies the GT predicate on the "updatedAt" field. +func UpdatedAtGT(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGT(FieldUpdatedAt, v)) +} + +// UpdatedAtGTE applies the GTE predicate on the "updatedAt" field. +func UpdatedAtGTE(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldGTE(FieldUpdatedAt, v)) +} + +// UpdatedAtLT applies the LT predicate on the "updatedAt" field. +func UpdatedAtLT(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLT(FieldUpdatedAt, v)) +} + +// UpdatedAtLTE applies the LTE predicate on the "updatedAt" field. +func UpdatedAtLTE(v int64) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.FieldLTE(FieldUpdatedAt, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.StationTerminalState) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.StationTerminalState) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.StationTerminalState) predicate.StationTerminalState { + return predicate.StationTerminalState(sql.NotPredicates(p)) +} diff --git a/bj_power_mes/ent/stationterminalstate_create.go b/bj_power_mes/ent/stationterminalstate_create.go new file mode 100644 index 0000000..453f089 --- /dev/null +++ b/bj_power_mes/ent/stationterminalstate_create.go @@ -0,0 +1,361 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/stationterminalstate" + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// StationTerminalStateCreate is the builder for creating a StationTerminalState entity. +type StationTerminalStateCreate struct { + config + mutation *StationTerminalStateMutation + hooks []Hook +} + +// SetStationNo sets the "stationNo" field. +func (_c *StationTerminalStateCreate) SetStationNo(v int) *StationTerminalStateCreate { + _c.mutation.SetStationNo(v) + return _c +} + +// SetPowered sets the "powered" field. +func (_c *StationTerminalStateCreate) SetPowered(v bool) *StationTerminalStateCreate { + _c.mutation.SetPowered(v) + return _c +} + +// SetNillablePowered sets the "powered" field if the given value is not nil. +func (_c *StationTerminalStateCreate) SetNillablePowered(v *bool) *StationTerminalStateCreate { + if v != nil { + _c.SetPowered(*v) + } + return _c +} + +// SetLoggedIn sets the "loggedIn" field. +func (_c *StationTerminalStateCreate) SetLoggedIn(v bool) *StationTerminalStateCreate { + _c.mutation.SetLoggedIn(v) + return _c +} + +// SetNillableLoggedIn sets the "loggedIn" field if the given value is not nil. +func (_c *StationTerminalStateCreate) SetNillableLoggedIn(v *bool) *StationTerminalStateCreate { + if v != nil { + _c.SetLoggedIn(*v) + } + return _c +} + +// SetOperator sets the "operator" field. +func (_c *StationTerminalStateCreate) SetOperator(v string) *StationTerminalStateCreate { + _c.mutation.SetOperator(v) + return _c +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_c *StationTerminalStateCreate) SetNillableOperator(v *string) *StationTerminalStateCreate { + if v != nil { + _c.SetOperator(*v) + } + return _c +} + +// SetPaused sets the "paused" field. +func (_c *StationTerminalStateCreate) SetPaused(v bool) *StationTerminalStateCreate { + _c.mutation.SetPaused(v) + return _c +} + +// SetNillablePaused sets the "paused" field if the given value is not nil. +func (_c *StationTerminalStateCreate) SetNillablePaused(v *bool) *StationTerminalStateCreate { + if v != nil { + _c.SetPaused(*v) + } + return _c +} + +// SetLastHeartbeatAt sets the "lastHeartbeatAt" field. +func (_c *StationTerminalStateCreate) SetLastHeartbeatAt(v int64) *StationTerminalStateCreate { + _c.mutation.SetLastHeartbeatAt(v) + return _c +} + +// SetNillableLastHeartbeatAt sets the "lastHeartbeatAt" field if the given value is not nil. +func (_c *StationTerminalStateCreate) SetNillableLastHeartbeatAt(v *int64) *StationTerminalStateCreate { + if v != nil { + _c.SetLastHeartbeatAt(*v) + } + return _c +} + +// SetUpdatedAt sets the "updatedAt" field. +func (_c *StationTerminalStateCreate) SetUpdatedAt(v int64) *StationTerminalStateCreate { + _c.mutation.SetUpdatedAt(v) + return _c +} + +// SetNillableUpdatedAt sets the "updatedAt" field if the given value is not nil. +func (_c *StationTerminalStateCreate) SetNillableUpdatedAt(v *int64) *StationTerminalStateCreate { + if v != nil { + _c.SetUpdatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *StationTerminalStateCreate) SetID(v int) *StationTerminalStateCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the StationTerminalStateMutation object of the builder. +func (_c *StationTerminalStateCreate) Mutation() *StationTerminalStateMutation { + return _c.mutation +} + +// Save creates the StationTerminalState in the database. +func (_c *StationTerminalStateCreate) Save(ctx context.Context) (*StationTerminalState, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *StationTerminalStateCreate) SaveX(ctx context.Context) *StationTerminalState { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *StationTerminalStateCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *StationTerminalStateCreate) 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 *StationTerminalStateCreate) defaults() { + if _, ok := _c.mutation.Powered(); !ok { + v := stationterminalstate.DefaultPowered + _c.mutation.SetPowered(v) + } + if _, ok := _c.mutation.LoggedIn(); !ok { + v := stationterminalstate.DefaultLoggedIn + _c.mutation.SetLoggedIn(v) + } + if _, ok := _c.mutation.Operator(); !ok { + v := stationterminalstate.DefaultOperator + _c.mutation.SetOperator(v) + } + if _, ok := _c.mutation.Paused(); !ok { + v := stationterminalstate.DefaultPaused + _c.mutation.SetPaused(v) + } + if _, ok := _c.mutation.LastHeartbeatAt(); !ok { + v := stationterminalstate.DefaultLastHeartbeatAt + _c.mutation.SetLastHeartbeatAt(v) + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + v := stationterminalstate.DefaultUpdatedAt + _c.mutation.SetUpdatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *StationTerminalStateCreate) check() error { + if _, ok := _c.mutation.StationNo(); !ok { + return &ValidationError{Name: "stationNo", err: errors.New(`ent: missing required field "StationTerminalState.stationNo"`)} + } + if _, ok := _c.mutation.Powered(); !ok { + return &ValidationError{Name: "powered", err: errors.New(`ent: missing required field "StationTerminalState.powered"`)} + } + if _, ok := _c.mutation.LoggedIn(); !ok { + return &ValidationError{Name: "loggedIn", err: errors.New(`ent: missing required field "StationTerminalState.loggedIn"`)} + } + if _, ok := _c.mutation.Operator(); !ok { + return &ValidationError{Name: "operator", err: errors.New(`ent: missing required field "StationTerminalState.operator"`)} + } + if v, ok := _c.mutation.Operator(); ok { + if err := stationterminalstate.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationTerminalState.operator": %w`, err)} + } + } + if _, ok := _c.mutation.Paused(); !ok { + return &ValidationError{Name: "paused", err: errors.New(`ent: missing required field "StationTerminalState.paused"`)} + } + if _, ok := _c.mutation.LastHeartbeatAt(); !ok { + return &ValidationError{Name: "lastHeartbeatAt", err: errors.New(`ent: missing required field "StationTerminalState.lastHeartbeatAt"`)} + } + if _, ok := _c.mutation.UpdatedAt(); !ok { + return &ValidationError{Name: "updatedAt", err: errors.New(`ent: missing required field "StationTerminalState.updatedAt"`)} + } + if v, ok := _c.mutation.ID(); ok { + if err := stationterminalstate.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "StationTerminalState.id": %w`, err)} + } + } + return nil +} + +func (_c *StationTerminalStateCreate) sqlSave(ctx context.Context) (*StationTerminalState, 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 *StationTerminalStateCreate) createSpec() (*StationTerminalState, *sqlgraph.CreateSpec) { + var ( + _node = &StationTerminalState{config: _c.config} + _spec = sqlgraph.NewCreateSpec(stationterminalstate.Table, sqlgraph.NewFieldSpec(stationterminalstate.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(stationterminalstate.FieldStationNo, field.TypeInt, value) + _node.StationNo = value + } + if value, ok := _c.mutation.Powered(); ok { + _spec.SetField(stationterminalstate.FieldPowered, field.TypeBool, value) + _node.Powered = value + } + if value, ok := _c.mutation.LoggedIn(); ok { + _spec.SetField(stationterminalstate.FieldLoggedIn, field.TypeBool, value) + _node.LoggedIn = value + } + if value, ok := _c.mutation.Operator(); ok { + _spec.SetField(stationterminalstate.FieldOperator, field.TypeString, value) + _node.Operator = value + } + if value, ok := _c.mutation.Paused(); ok { + _spec.SetField(stationterminalstate.FieldPaused, field.TypeBool, value) + _node.Paused = value + } + if value, ok := _c.mutation.LastHeartbeatAt(); ok { + _spec.SetField(stationterminalstate.FieldLastHeartbeatAt, field.TypeInt64, value) + _node.LastHeartbeatAt = value + } + if value, ok := _c.mutation.UpdatedAt(); ok { + _spec.SetField(stationterminalstate.FieldUpdatedAt, field.TypeInt64, value) + _node.UpdatedAt = value + } + return _node, _spec +} + +// StationTerminalStateCreateBulk is the builder for creating many StationTerminalState entities in bulk. +type StationTerminalStateCreateBulk struct { + config + err error + builders []*StationTerminalStateCreate +} + +// Save creates the StationTerminalState entities in the database. +func (_c *StationTerminalStateCreateBulk) Save(ctx context.Context) ([]*StationTerminalState, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*StationTerminalState, 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.(*StationTerminalStateMutation) + 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 *StationTerminalStateCreateBulk) SaveX(ctx context.Context) []*StationTerminalState { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *StationTerminalStateCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *StationTerminalStateCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/stationterminalstate_delete.go b/bj_power_mes/ent/stationterminalstate_delete.go new file mode 100644 index 0000000..230fe87 --- /dev/null +++ b/bj_power_mes/ent/stationterminalstate_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/stationterminalstate" + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// StationTerminalStateDelete is the builder for deleting a StationTerminalState entity. +type StationTerminalStateDelete struct { + config + hooks []Hook + mutation *StationTerminalStateMutation +} + +// Where appends a list predicates to the StationTerminalStateDelete builder. +func (_d *StationTerminalStateDelete) Where(ps ...predicate.StationTerminalState) *StationTerminalStateDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *StationTerminalStateDelete) 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 *StationTerminalStateDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *StationTerminalStateDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(stationterminalstate.Table, sqlgraph.NewFieldSpec(stationterminalstate.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 +} + +// StationTerminalStateDeleteOne is the builder for deleting a single StationTerminalState entity. +type StationTerminalStateDeleteOne struct { + _d *StationTerminalStateDelete +} + +// Where appends a list predicates to the StationTerminalStateDelete builder. +func (_d *StationTerminalStateDeleteOne) Where(ps ...predicate.StationTerminalState) *StationTerminalStateDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *StationTerminalStateDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{stationterminalstate.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *StationTerminalStateDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/stationterminalstate_query.go b/bj_power_mes/ent/stationterminalstate_query.go new file mode 100644 index 0000000..a9dd448 --- /dev/null +++ b/bj_power_mes/ent/stationterminalstate_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/stationterminalstate" + "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" +) + +// StationTerminalStateQuery is the builder for querying StationTerminalState entities. +type StationTerminalStateQuery struct { + config + ctx *QueryContext + order []stationterminalstate.OrderOption + inters []Interceptor + predicates []predicate.StationTerminalState + 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 StationTerminalStateQuery builder. +func (_q *StationTerminalStateQuery) Where(ps ...predicate.StationTerminalState) *StationTerminalStateQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *StationTerminalStateQuery) Limit(limit int) *StationTerminalStateQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *StationTerminalStateQuery) Offset(offset int) *StationTerminalStateQuery { + _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 *StationTerminalStateQuery) Unique(unique bool) *StationTerminalStateQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *StationTerminalStateQuery) Order(o ...stationterminalstate.OrderOption) *StationTerminalStateQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first StationTerminalState entity from the query. +// Returns a *NotFoundError when no StationTerminalState was found. +func (_q *StationTerminalStateQuery) First(ctx context.Context) (*StationTerminalState, 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{stationterminalstate.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *StationTerminalStateQuery) FirstX(ctx context.Context) *StationTerminalState { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first StationTerminalState ID from the query. +// Returns a *NotFoundError when no StationTerminalState ID was found. +func (_q *StationTerminalStateQuery) 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{stationterminalstate.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *StationTerminalStateQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single StationTerminalState entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one StationTerminalState entity is found. +// Returns a *NotFoundError when no StationTerminalState entities are found. +func (_q *StationTerminalStateQuery) Only(ctx context.Context) (*StationTerminalState, 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{stationterminalstate.Label} + default: + return nil, &NotSingularError{stationterminalstate.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *StationTerminalStateQuery) OnlyX(ctx context.Context) *StationTerminalState { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only StationTerminalState ID in the query. +// Returns a *NotSingularError when more than one StationTerminalState ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *StationTerminalStateQuery) 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{stationterminalstate.Label} + default: + err = &NotSingularError{stationterminalstate.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *StationTerminalStateQuery) 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 StationTerminalStates. +func (_q *StationTerminalStateQuery) All(ctx context.Context) ([]*StationTerminalState, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*StationTerminalState, *StationTerminalStateQuery]() + return withInterceptors[[]*StationTerminalState](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *StationTerminalStateQuery) AllX(ctx context.Context) []*StationTerminalState { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of StationTerminalState IDs. +func (_q *StationTerminalStateQuery) 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(stationterminalstate.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *StationTerminalStateQuery) 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 *StationTerminalStateQuery) 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[*StationTerminalStateQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *StationTerminalStateQuery) 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 *StationTerminalStateQuery) 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 *StationTerminalStateQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the StationTerminalStateQuery 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 *StationTerminalStateQuery) Clone() *StationTerminalStateQuery { + if _q == nil { + return nil + } + return &StationTerminalStateQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]stationterminalstate.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.StationTerminalState{}, _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 { +// StationNo int `json:"stationNo,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.StationTerminalState.Query(). +// GroupBy(stationterminalstate.FieldStationNo). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *StationTerminalStateQuery) GroupBy(field string, fields ...string) *StationTerminalStateGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &StationTerminalStateGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = stationterminalstate.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 { +// StationNo int `json:"stationNo,omitempty"` +// } +// +// client.StationTerminalState.Query(). +// Select(stationterminalstate.FieldStationNo). +// Scan(ctx, &v) +func (_q *StationTerminalStateQuery) Select(fields ...string) *StationTerminalStateSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &StationTerminalStateSelect{StationTerminalStateQuery: _q} + sbuild.label = stationterminalstate.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a StationTerminalStateSelect configured with the given aggregations. +func (_q *StationTerminalStateQuery) Aggregate(fns ...AggregateFunc) *StationTerminalStateSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *StationTerminalStateQuery) 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 !stationterminalstate.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 *StationTerminalStateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*StationTerminalState, error) { + var ( + nodes = []*StationTerminalState{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*StationTerminalState).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &StationTerminalState{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 *StationTerminalStateQuery) 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 *StationTerminalStateQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(stationterminalstate.Table, stationterminalstate.Columns, sqlgraph.NewFieldSpec(stationterminalstate.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, stationterminalstate.FieldID) + for i := range fields { + if fields[i] != stationterminalstate.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 *StationTerminalStateQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(stationterminalstate.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = stationterminalstate.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 *StationTerminalStateQuery) ForUpdate(opts ...sql.LockOption) *StationTerminalStateQuery { + 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 *StationTerminalStateQuery) ForShare(opts ...sql.LockOption) *StationTerminalStateQuery { + 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 *StationTerminalStateQuery) Modify(modifiers ...func(s *sql.Selector)) *StationTerminalStateSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// StationTerminalStateGroupBy is the group-by builder for StationTerminalState entities. +type StationTerminalStateGroupBy struct { + selector + build *StationTerminalStateQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *StationTerminalStateGroupBy) Aggregate(fns ...AggregateFunc) *StationTerminalStateGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *StationTerminalStateGroupBy) 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[*StationTerminalStateQuery, *StationTerminalStateGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *StationTerminalStateGroupBy) sqlScan(ctx context.Context, root *StationTerminalStateQuery, 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) +} + +// StationTerminalStateSelect is the builder for selecting fields of StationTerminalState entities. +type StationTerminalStateSelect struct { + *StationTerminalStateQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *StationTerminalStateSelect) Aggregate(fns ...AggregateFunc) *StationTerminalStateSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *StationTerminalStateSelect) 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[*StationTerminalStateQuery, *StationTerminalStateSelect](ctx, _s.StationTerminalStateQuery, _s, _s.inters, v) +} + +func (_s *StationTerminalStateSelect) sqlScan(ctx context.Context, root *StationTerminalStateQuery, 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 *StationTerminalStateSelect) Modify(modifiers ...func(s *sql.Selector)) *StationTerminalStateSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/bj_power_mes/ent/stationterminalstate_update.go b/bj_power_mes/ent/stationterminalstate_update.go new file mode 100644 index 0000000..a1a1612 --- /dev/null +++ b/bj_power_mes/ent/stationterminalstate_update.go @@ -0,0 +1,515 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/predicate" + "bj_power_mes/ent/stationterminalstate" + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// StationTerminalStateUpdate is the builder for updating StationTerminalState entities. +type StationTerminalStateUpdate struct { + config + hooks []Hook + mutation *StationTerminalStateMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the StationTerminalStateUpdate builder. +func (_u *StationTerminalStateUpdate) Where(ps ...predicate.StationTerminalState) *StationTerminalStateUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetStationNo sets the "stationNo" field. +func (_u *StationTerminalStateUpdate) SetStationNo(v int) *StationTerminalStateUpdate { + _u.mutation.ResetStationNo() + _u.mutation.SetStationNo(v) + return _u +} + +// SetNillableStationNo sets the "stationNo" field if the given value is not nil. +func (_u *StationTerminalStateUpdate) SetNillableStationNo(v *int) *StationTerminalStateUpdate { + if v != nil { + _u.SetStationNo(*v) + } + return _u +} + +// AddStationNo adds value to the "stationNo" field. +func (_u *StationTerminalStateUpdate) AddStationNo(v int) *StationTerminalStateUpdate { + _u.mutation.AddStationNo(v) + return _u +} + +// SetPowered sets the "powered" field. +func (_u *StationTerminalStateUpdate) SetPowered(v bool) *StationTerminalStateUpdate { + _u.mutation.SetPowered(v) + return _u +} + +// SetNillablePowered sets the "powered" field if the given value is not nil. +func (_u *StationTerminalStateUpdate) SetNillablePowered(v *bool) *StationTerminalStateUpdate { + if v != nil { + _u.SetPowered(*v) + } + return _u +} + +// SetLoggedIn sets the "loggedIn" field. +func (_u *StationTerminalStateUpdate) SetLoggedIn(v bool) *StationTerminalStateUpdate { + _u.mutation.SetLoggedIn(v) + return _u +} + +// SetNillableLoggedIn sets the "loggedIn" field if the given value is not nil. +func (_u *StationTerminalStateUpdate) SetNillableLoggedIn(v *bool) *StationTerminalStateUpdate { + if v != nil { + _u.SetLoggedIn(*v) + } + return _u +} + +// SetOperator sets the "operator" field. +func (_u *StationTerminalStateUpdate) SetOperator(v string) *StationTerminalStateUpdate { + _u.mutation.SetOperator(v) + return _u +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_u *StationTerminalStateUpdate) SetNillableOperator(v *string) *StationTerminalStateUpdate { + if v != nil { + _u.SetOperator(*v) + } + return _u +} + +// SetPaused sets the "paused" field. +func (_u *StationTerminalStateUpdate) SetPaused(v bool) *StationTerminalStateUpdate { + _u.mutation.SetPaused(v) + return _u +} + +// SetNillablePaused sets the "paused" field if the given value is not nil. +func (_u *StationTerminalStateUpdate) SetNillablePaused(v *bool) *StationTerminalStateUpdate { + if v != nil { + _u.SetPaused(*v) + } + return _u +} + +// SetLastHeartbeatAt sets the "lastHeartbeatAt" field. +func (_u *StationTerminalStateUpdate) SetLastHeartbeatAt(v int64) *StationTerminalStateUpdate { + _u.mutation.ResetLastHeartbeatAt() + _u.mutation.SetLastHeartbeatAt(v) + return _u +} + +// SetNillableLastHeartbeatAt sets the "lastHeartbeatAt" field if the given value is not nil. +func (_u *StationTerminalStateUpdate) SetNillableLastHeartbeatAt(v *int64) *StationTerminalStateUpdate { + if v != nil { + _u.SetLastHeartbeatAt(*v) + } + return _u +} + +// AddLastHeartbeatAt adds value to the "lastHeartbeatAt" field. +func (_u *StationTerminalStateUpdate) AddLastHeartbeatAt(v int64) *StationTerminalStateUpdate { + _u.mutation.AddLastHeartbeatAt(v) + return _u +} + +// SetUpdatedAt sets the "updatedAt" field. +func (_u *StationTerminalStateUpdate) SetUpdatedAt(v int64) *StationTerminalStateUpdate { + _u.mutation.ResetUpdatedAt() + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetNillableUpdatedAt sets the "updatedAt" field if the given value is not nil. +func (_u *StationTerminalStateUpdate) SetNillableUpdatedAt(v *int64) *StationTerminalStateUpdate { + if v != nil { + _u.SetUpdatedAt(*v) + } + return _u +} + +// AddUpdatedAt adds value to the "updatedAt" field. +func (_u *StationTerminalStateUpdate) AddUpdatedAt(v int64) *StationTerminalStateUpdate { + _u.mutation.AddUpdatedAt(v) + return _u +} + +// Mutation returns the StationTerminalStateMutation object of the builder. +func (_u *StationTerminalStateUpdate) Mutation() *StationTerminalStateMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *StationTerminalStateUpdate) 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 *StationTerminalStateUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *StationTerminalStateUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *StationTerminalStateUpdate) 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 *StationTerminalStateUpdate) check() error { + if v, ok := _u.mutation.Operator(); ok { + if err := stationterminalstate.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationTerminalState.operator": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *StationTerminalStateUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationTerminalStateUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *StationTerminalStateUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(stationterminalstate.Table, stationterminalstate.Columns, sqlgraph.NewFieldSpec(stationterminalstate.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.StationNo(); ok { + _spec.SetField(stationterminalstate.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStationNo(); ok { + _spec.AddField(stationterminalstate.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.Powered(); ok { + _spec.SetField(stationterminalstate.FieldPowered, field.TypeBool, value) + } + if value, ok := _u.mutation.LoggedIn(); ok { + _spec.SetField(stationterminalstate.FieldLoggedIn, field.TypeBool, value) + } + if value, ok := _u.mutation.Operator(); ok { + _spec.SetField(stationterminalstate.FieldOperator, field.TypeString, value) + } + if value, ok := _u.mutation.Paused(); ok { + _spec.SetField(stationterminalstate.FieldPaused, field.TypeBool, value) + } + if value, ok := _u.mutation.LastHeartbeatAt(); ok { + _spec.SetField(stationterminalstate.FieldLastHeartbeatAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedLastHeartbeatAt(); ok { + _spec.AddField(stationterminalstate.FieldLastHeartbeatAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(stationterminalstate.FieldUpdatedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedUpdatedAt(); ok { + _spec.AddField(stationterminalstate.FieldUpdatedAt, field.TypeInt64, value) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{stationterminalstate.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// StationTerminalStateUpdateOne is the builder for updating a single StationTerminalState entity. +type StationTerminalStateUpdateOne struct { + config + fields []string + hooks []Hook + mutation *StationTerminalStateMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetStationNo sets the "stationNo" field. +func (_u *StationTerminalStateUpdateOne) SetStationNo(v int) *StationTerminalStateUpdateOne { + _u.mutation.ResetStationNo() + _u.mutation.SetStationNo(v) + return _u +} + +// SetNillableStationNo sets the "stationNo" field if the given value is not nil. +func (_u *StationTerminalStateUpdateOne) SetNillableStationNo(v *int) *StationTerminalStateUpdateOne { + if v != nil { + _u.SetStationNo(*v) + } + return _u +} + +// AddStationNo adds value to the "stationNo" field. +func (_u *StationTerminalStateUpdateOne) AddStationNo(v int) *StationTerminalStateUpdateOne { + _u.mutation.AddStationNo(v) + return _u +} + +// SetPowered sets the "powered" field. +func (_u *StationTerminalStateUpdateOne) SetPowered(v bool) *StationTerminalStateUpdateOne { + _u.mutation.SetPowered(v) + return _u +} + +// SetNillablePowered sets the "powered" field if the given value is not nil. +func (_u *StationTerminalStateUpdateOne) SetNillablePowered(v *bool) *StationTerminalStateUpdateOne { + if v != nil { + _u.SetPowered(*v) + } + return _u +} + +// SetLoggedIn sets the "loggedIn" field. +func (_u *StationTerminalStateUpdateOne) SetLoggedIn(v bool) *StationTerminalStateUpdateOne { + _u.mutation.SetLoggedIn(v) + return _u +} + +// SetNillableLoggedIn sets the "loggedIn" field if the given value is not nil. +func (_u *StationTerminalStateUpdateOne) SetNillableLoggedIn(v *bool) *StationTerminalStateUpdateOne { + if v != nil { + _u.SetLoggedIn(*v) + } + return _u +} + +// SetOperator sets the "operator" field. +func (_u *StationTerminalStateUpdateOne) SetOperator(v string) *StationTerminalStateUpdateOne { + _u.mutation.SetOperator(v) + return _u +} + +// SetNillableOperator sets the "operator" field if the given value is not nil. +func (_u *StationTerminalStateUpdateOne) SetNillableOperator(v *string) *StationTerminalStateUpdateOne { + if v != nil { + _u.SetOperator(*v) + } + return _u +} + +// SetPaused sets the "paused" field. +func (_u *StationTerminalStateUpdateOne) SetPaused(v bool) *StationTerminalStateUpdateOne { + _u.mutation.SetPaused(v) + return _u +} + +// SetNillablePaused sets the "paused" field if the given value is not nil. +func (_u *StationTerminalStateUpdateOne) SetNillablePaused(v *bool) *StationTerminalStateUpdateOne { + if v != nil { + _u.SetPaused(*v) + } + return _u +} + +// SetLastHeartbeatAt sets the "lastHeartbeatAt" field. +func (_u *StationTerminalStateUpdateOne) SetLastHeartbeatAt(v int64) *StationTerminalStateUpdateOne { + _u.mutation.ResetLastHeartbeatAt() + _u.mutation.SetLastHeartbeatAt(v) + return _u +} + +// SetNillableLastHeartbeatAt sets the "lastHeartbeatAt" field if the given value is not nil. +func (_u *StationTerminalStateUpdateOne) SetNillableLastHeartbeatAt(v *int64) *StationTerminalStateUpdateOne { + if v != nil { + _u.SetLastHeartbeatAt(*v) + } + return _u +} + +// AddLastHeartbeatAt adds value to the "lastHeartbeatAt" field. +func (_u *StationTerminalStateUpdateOne) AddLastHeartbeatAt(v int64) *StationTerminalStateUpdateOne { + _u.mutation.AddLastHeartbeatAt(v) + return _u +} + +// SetUpdatedAt sets the "updatedAt" field. +func (_u *StationTerminalStateUpdateOne) SetUpdatedAt(v int64) *StationTerminalStateUpdateOne { + _u.mutation.ResetUpdatedAt() + _u.mutation.SetUpdatedAt(v) + return _u +} + +// SetNillableUpdatedAt sets the "updatedAt" field if the given value is not nil. +func (_u *StationTerminalStateUpdateOne) SetNillableUpdatedAt(v *int64) *StationTerminalStateUpdateOne { + if v != nil { + _u.SetUpdatedAt(*v) + } + return _u +} + +// AddUpdatedAt adds value to the "updatedAt" field. +func (_u *StationTerminalStateUpdateOne) AddUpdatedAt(v int64) *StationTerminalStateUpdateOne { + _u.mutation.AddUpdatedAt(v) + return _u +} + +// Mutation returns the StationTerminalStateMutation object of the builder. +func (_u *StationTerminalStateUpdateOne) Mutation() *StationTerminalStateMutation { + return _u.mutation +} + +// Where appends a list predicates to the StationTerminalStateUpdate builder. +func (_u *StationTerminalStateUpdateOne) Where(ps ...predicate.StationTerminalState) *StationTerminalStateUpdateOne { + _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 *StationTerminalStateUpdateOne) Select(field string, fields ...string) *StationTerminalStateUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated StationTerminalState entity. +func (_u *StationTerminalStateUpdateOne) Save(ctx context.Context) (*StationTerminalState, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *StationTerminalStateUpdateOne) SaveX(ctx context.Context) *StationTerminalState { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *StationTerminalStateUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *StationTerminalStateUpdateOne) 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 *StationTerminalStateUpdateOne) check() error { + if v, ok := _u.mutation.Operator(); ok { + if err := stationterminalstate.OperatorValidator(v); err != nil { + return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationTerminalState.operator": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *StationTerminalStateUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationTerminalStateUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *StationTerminalStateUpdateOne) sqlSave(ctx context.Context) (_node *StationTerminalState, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(stationterminalstate.Table, stationterminalstate.Columns, sqlgraph.NewFieldSpec(stationterminalstate.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "StationTerminalState.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, stationterminalstate.FieldID) + for _, f := range fields { + if !stationterminalstate.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != stationterminalstate.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.StationNo(); ok { + _spec.SetField(stationterminalstate.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedStationNo(); ok { + _spec.AddField(stationterminalstate.FieldStationNo, field.TypeInt, value) + } + if value, ok := _u.mutation.Powered(); ok { + _spec.SetField(stationterminalstate.FieldPowered, field.TypeBool, value) + } + if value, ok := _u.mutation.LoggedIn(); ok { + _spec.SetField(stationterminalstate.FieldLoggedIn, field.TypeBool, value) + } + if value, ok := _u.mutation.Operator(); ok { + _spec.SetField(stationterminalstate.FieldOperator, field.TypeString, value) + } + if value, ok := _u.mutation.Paused(); ok { + _spec.SetField(stationterminalstate.FieldPaused, field.TypeBool, value) + } + if value, ok := _u.mutation.LastHeartbeatAt(); ok { + _spec.SetField(stationterminalstate.FieldLastHeartbeatAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedLastHeartbeatAt(); ok { + _spec.AddField(stationterminalstate.FieldLastHeartbeatAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.UpdatedAt(); ok { + _spec.SetField(stationterminalstate.FieldUpdatedAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedUpdatedAt(); ok { + _spec.AddField(stationterminalstate.FieldUpdatedAt, field.TypeInt64, value) + } + _spec.AddModifiers(_u.modifiers...) + _node = &StationTerminalState{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{stationterminalstate.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/ent/tx.go b/bj_power_mes/ent/tx.go index 8b23a41..a13b4ab 100644 --- a/bj_power_mes/ent/tx.go +++ b/bj_power_mes/ent/tx.go @@ -76,6 +76,10 @@ type Tx struct { StationShift *StationShiftClient // StationState is the client for interacting with the StationState builders. StationState *StationStateClient + // StationTerminalEvent is the client for interacting with the StationTerminalEvent builders. + StationTerminalEvent *StationTerminalEventClient + // StationTerminalState is the client for interacting with the StationTerminalState builders. + StationTerminalState *StationTerminalStateClient // StepCriterion is the client for interacting with the StepCriterion builders. StepCriterion *StepCriterionClient // StepData is the client for interacting with the StepData builders. @@ -267,6 +271,8 @@ func (tx *Tx) init() { tx.Station = NewStationClient(tx.config) tx.StationShift = NewStationShiftClient(tx.config) tx.StationState = NewStationStateClient(tx.config) + tx.StationTerminalEvent = NewStationTerminalEventClient(tx.config) + tx.StationTerminalState = NewStationTerminalStateClient(tx.config) tx.StepCriterion = NewStepCriterionClient(tx.config) tx.StepData = NewStepDataClient(tx.config) tx.StepSignRecord = NewStepSignRecordClient(tx.config) diff --git a/bj_power_mes/frontend/src/components/NextStepBar.vue b/bj_power_mes/frontend/src/components/NextStepBar.vue index 1c2b982..02a0b61 100644 --- a/bj_power_mes/frontend/src/components/NextStepBar.vue +++ b/bj_power_mes/frontend/src/components/NextStepBar.vue @@ -1,7 +1,7 @@ diff --git a/bj_power_mes/frontend/src/pages/MaterialRequest.vue b/bj_power_mes/frontend/src/pages/MaterialRequest.vue index d36c55c..9ee6b2f 100644 --- a/bj_power_mes/frontend/src/pages/MaterialRequest.vue +++ b/bj_power_mes/frontend/src/pages/MaterialRequest.vue @@ -94,13 +94,7 @@ - - - - + MES 侧只读展示差异,不再设「确认损耗」按钮;损耗台账页仅展示(只读,无批注动作)。 --> @@ -110,7 +104,6 @@ + + diff --git a/bj_power_mes/frontend/src/pages/TorqueGunConfig.vue b/bj_power_mes/frontend/src/pages/TorqueGunConfig.vue index 29cc820..dcd8c1d 100644 --- a/bj_power_mes/frontend/src/pages/TorqueGunConfig.vue +++ b/bj_power_mes/frontend/src/pages/TorqueGunConfig.vue @@ -8,13 +8,12 @@
控制器地址是什么用:填的是该工位拧紧枪控制器的网络地址(IP:端口,如 127.0.0.1:4545), - 仅作现场设备档案登记与「是否接了控制器」的判断依据:只有填了控制器地址,才能关闭该工位的「允许手填」。 - 系统不会用这个地址主动连设备,也不下发到工位终端;地址由工位终端启动时上报本页初始化,已有配置不会被覆盖。 + 仅作现场设备档案登记与「是否接了控制器」的判断依据。系统不会用这个地址主动连设备,也不下发到工位终端; + 地址由工位终端启动时上报本页初始化,已有配置不会被覆盖。
- 「允许手填」按工位配置:实体工位接了控制器可关闭手填,线下虚拟位不接控制器默认允许手填。 - 本页只允许修改已有工位的控制器地址与手填开关,不能新增控制器行(工位清单来自工位管理)。 - 修改后即时保存,无需点保存按钮。 + 2026-11-26 起不再有「允许手填」开关:拧紧数据只认设备上报,系统不录标准、不按标准判定。 + 本页只允许修改已有工位的控制器地址与枪通道号,不能新增控制器行(工位清单来自工位管理),改完即时保存。
@@ -43,11 +42,6 @@
- - -