From b032f47fc7fb84d19f8cc4a561af5aff793f89ba Mon Sep 17 00:00:00 2001 From: SunYF <123@hard_man.com> Date: Fri, 9 Oct 2026 13:46:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=B7=A5=E8=89=BA=E7=AE=A1=E7=90=86=E4=B8=8E=E5=B7=A5=E5=BA=8F?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增产品工艺(product_process)及明细(product_process_item)数据模型 - 新增工序审核开关(need_audit)与审核角色(audit_role)字段 - 新增待审核签字页面与路由 - 优化 WMS/MES 接口交互,增加业务错误处理与友好提示 - 补充库存过滤逻辑,避免返回已出库 SN 数据 - 调整默认查询时间范围为近一个月,优化用户体验 --- bj_power_mes/ent/client.go | 451 ++++- bj_power_mes/ent/ent.go | 68 +- bj_power_mes/ent/hook/hook.go | 24 + bj_power_mes/ent/migrate/schema.go | 70 +- bj_power_mes/ent/mutation.go | 1538 ++++++++++++++++- bj_power_mes/ent/predicate/predicate.go | 6 + bj_power_mes/ent/processstep.go | 26 +- bj_power_mes/ent/processstep/processstep.go | 22 + bj_power_mes/ent/processstep/where.go | 95 + bj_power_mes/ent/processstep_create.go | 52 + bj_power_mes/ent/processstep_update.go | 96 + bj_power_mes/ent/productprocess.go | 174 ++ .../ent/productprocess/productprocess.go | 122 ++ bj_power_mes/ent/productprocess/where.go | 480 +++++ bj_power_mes/ent/productprocess_create.go | 370 ++++ bj_power_mes/ent/productprocess_delete.go | 88 + bj_power_mes/ent/productprocess_query.go | 577 +++++++ bj_power_mes/ent/productprocess_update.go | 461 +++++ bj_power_mes/ent/productprocessitem.go | 137 ++ .../productprocessitem/productprocessitem.go | 80 + bj_power_mes/ent/productprocessitem/where.go | 250 +++ bj_power_mes/ent/productprocessitem_create.go | 258 +++ bj_power_mes/ent/productprocessitem_delete.go | 88 + bj_power_mes/ent/productprocessitem_query.go | 577 +++++++ bj_power_mes/ent/productprocessitem_update.go | 353 ++++ bj_power_mes/ent/runtime.go | 76 +- bj_power_mes/ent/tx.go | 6 + bj_power_mes/ent/workorder.go | 13 +- bj_power_mes/ent/workorder/where.go | 45 + bj_power_mes/ent/workorder/workorder.go | 10 + bj_power_mes/ent/workorder_create.go | 25 + bj_power_mes/ent/workorder_update.go | 54 + bj_power_mes/frontend/src/help.js | 42 +- .../frontend/src/layouts/MainLayout.vue | 2 + .../frontend/src/pages/AccountManage.vue | 2 +- .../frontend/src/pages/AlertCenter.vue | 11 +- .../frontend/src/pages/AuditPending.vue | 125 ++ bj_power_mes/frontend/src/pages/DailyPlan.vue | 79 +- bj_power_mes/frontend/src/pages/Inspect.vue | 25 +- bj_power_mes/frontend/src/pages/PlcSend.vue | 46 +- .../frontend/src/pages/ProcessCard.vue | 467 +++-- .../frontend/src/pages/ProcessFlow.vue | 50 +- .../frontend/src/pages/ProductProcess.vue | 281 +++ .../frontend/src/pages/ProductType.vue | 2 +- bj_power_mes/frontend/src/pages/Station.vue | 25 +- bj_power_mes/frontend/src/pages/Trace.vue | 26 +- bj_power_mes/frontend/src/pages/WorkOrder.vue | 96 +- bj_power_mes/frontend/src/router/index.js | 2 + bj_power_mes/frontend/src/utils/request.js | 20 +- bj_power_mes/internal/db/db.go | 9 + bj_power_mes/internal/handler/processcard.go | 339 ---- .../internal/handler/processcard_model.go | 593 ------- .../internal/handler/processcard_workorder.go | 1004 +++++++++++ bj_power_mes/internal/handler/processflow.go | 4 +- .../internal/handler/production/material.go | 39 +- .../internal/handler/production/production.go | 2 +- .../internal/handler/production/sign.go | 41 +- .../internal/handler/production/workorder.go | 16 +- .../handler/production/workpiece_semi.go | 9 +- .../internal/handler/productprocess.go | 88 + .../internal/handler/productprocess_card.go | 334 ++++ .../internal/handler/routes_production.go | 20 +- bj_power_mes/internal/logic/material.go | 80 +- bj_power_mes/internal/logic/processflow.go | 24 +- bj_power_mes/internal/logic/producible.go | 5 +- bj_power_mes/internal/logic/productprocess.go | 497 ++++++ bj_power_mes/internal/logic/seed.go | 8 + bj_power_mes/internal/logic/sign.go | 189 ++ bj_power_mes/internal/logic/workorder.go | 40 +- bj_power_mes/internal/logic/workpiece.go | 101 +- bj_power_mes/internal/wmsclient/client.go | 41 + bj_power_mes/public/index.html | 4 +- bj_power_mes/schema/process_step.go | 2 + bj_power_mes/schema/product_process.go | 46 + bj_power_mes/schema/product_process_item.go | 40 + bj_power_mes/schema/work_order.go | 3 + bj_power_wms/etc/aitest_wms.yaml | 69 + bj_power_wms/frontend/src/pages/Agv.vue | 4 +- bj_power_wms/frontend/src/pages/BaseData.vue | 2 +- bj_power_wms/frontend/src/pages/Inbound.vue | 4 +- .../frontend/src/pages/Inspection.vue | 29 +- bj_power_wms/frontend/src/pages/Outbound.vue | 4 +- .../frontend/src/pages/UserManage.vue | 2 +- bj_power_wms/frontend/src/utils/request.js | 16 +- bj_power_wms/internal/handler/excel.go | 95 +- bj_power_wms/internal/handler/material.go | 40 + bj_power_wms/internal/handler/routes.go | 1 + bj_power_wms/internal/handler/stock.go | 4 + bj_power_wms/web/static/index.html | 2 +- bj_power_workstation/internal/handler/auth.go | 8 + .../internal/handler/report.go | 65 +- .../internal/handler/workpiece.go | 38 +- bj_power_workstation/internal/mes/client.go | 19 +- bj_power_workstation/internal/store/store.go | 16 + .../internal/syncer/syncer.go | 14 + 95 files changed, 10546 insertions(+), 1457 deletions(-) create mode 100644 bj_power_mes/ent/productprocess.go create mode 100644 bj_power_mes/ent/productprocess/productprocess.go create mode 100644 bj_power_mes/ent/productprocess/where.go create mode 100644 bj_power_mes/ent/productprocess_create.go create mode 100644 bj_power_mes/ent/productprocess_delete.go create mode 100644 bj_power_mes/ent/productprocess_query.go create mode 100644 bj_power_mes/ent/productprocess_update.go create mode 100644 bj_power_mes/ent/productprocessitem.go create mode 100644 bj_power_mes/ent/productprocessitem/productprocessitem.go create mode 100644 bj_power_mes/ent/productprocessitem/where.go create mode 100644 bj_power_mes/ent/productprocessitem_create.go create mode 100644 bj_power_mes/ent/productprocessitem_delete.go create mode 100644 bj_power_mes/ent/productprocessitem_query.go create mode 100644 bj_power_mes/ent/productprocessitem_update.go create mode 100644 bj_power_mes/frontend/src/pages/AuditPending.vue create mode 100644 bj_power_mes/frontend/src/pages/ProductProcess.vue delete mode 100644 bj_power_mes/internal/handler/processcard.go delete mode 100644 bj_power_mes/internal/handler/processcard_model.go create mode 100644 bj_power_mes/internal/handler/processcard_workorder.go create mode 100644 bj_power_mes/internal/handler/productprocess.go create mode 100644 bj_power_mes/internal/handler/productprocess_card.go create mode 100644 bj_power_mes/internal/logic/productprocess.go create mode 100644 bj_power_mes/schema/product_process.go create mode 100644 bj_power_mes/schema/product_process_item.go create mode 100644 bj_power_wms/etc/aitest_wms.yaml diff --git a/bj_power_mes/ent/client.go b/bj_power_mes/ent/client.go index 003e8dd..c1d5196 100644 --- a/bj_power_mes/ent/client.go +++ b/bj_power_mes/ent/client.go @@ -28,6 +28,8 @@ import ( "bj_power_mes/ent/plcsendlog" "bj_power_mes/ent/processflow" "bj_power_mes/ent/processstep" + "bj_power_mes/ent/productprocess" + "bj_power_mes/ent/productprocessitem" "bj_power_mes/ent/role" "bj_power_mes/ent/semiflow" "bj_power_mes/ent/station" @@ -88,6 +90,10 @@ type Client struct { ProcessFlow *ProcessFlowClient // ProcessStep is the client for interacting with the ProcessStep builders. ProcessStep *ProcessStepClient + // ProductProcess is the client for interacting with the ProductProcess builders. + ProductProcess *ProductProcessClient + // ProductProcessItem is the client for interacting with the ProductProcessItem builders. + ProductProcessItem *ProductProcessItemClient // Role is the client for interacting with the Role builders. Role *RoleClient // SemiFlow is the client for interacting with the SemiFlow builders. @@ -146,6 +152,8 @@ func (c *Client) init() { c.PlcSendLog = NewPlcSendLogClient(c.config) c.ProcessFlow = NewProcessFlowClient(c.config) c.ProcessStep = NewProcessStepClient(c.config) + c.ProductProcess = NewProductProcessClient(c.config) + c.ProductProcessItem = NewProductProcessItemClient(c.config) c.Role = NewRoleClient(c.config) c.SemiFlow = NewSemiFlowClient(c.config) c.Station = NewStationClient(c.config) @@ -251,40 +259,42 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { cfg := c.config cfg.driver = tx return &Tx{ - ctx: ctx, - config: cfg, - Alert: NewAlertClient(cfg), - AlertRule: NewAlertRuleClient(cfg), - AssociationTrace: NewAssociationTraceClient(cfg), - Attachment: NewAttachmentClient(cfg), - DailyPlan: NewDailyPlanClient(cfg), - Dock: NewDockClient(cfg), - EventLog: NewEventLogClient(cfg), - FlowMaterial: NewFlowMaterialClient(cfg), - InspectionRecord: NewInspectionRecordClient(cfg), - LinePoint: NewLinePointClient(cfg), - Material: NewMaterialClient(cfg), - MaterialQtyReport: NewMaterialQtyReportClient(cfg), - MaterialRequest: NewMaterialRequestClient(cfg), - Permission: NewPermissionClient(cfg), - PlcSendLog: NewPlcSendLogClient(cfg), - ProcessFlow: NewProcessFlowClient(cfg), - ProcessStep: NewProcessStepClient(cfg), - Role: NewRoleClient(cfg), - SemiFlow: NewSemiFlowClient(cfg), - Station: NewStationClient(cfg), - StationState: NewStationStateClient(cfg), - StepCriterion: NewStepCriterionClient(cfg), - StepData: NewStepDataClient(cfg), - StepSignRecord: NewStepSignRecordClient(cfg), - SysConfig: NewSysConfigClient(cfg), - TorqueRecord: NewTorqueRecordClient(cfg), - User: NewUserClient(cfg), - UserStation: NewUserStationClient(cfg), - WorkOrder: NewWorkOrderClient(cfg), - Workpiece: NewWorkpieceClient(cfg), - WorkpieceBind: NewWorkpieceBindClient(cfg), - WorkpieceProcess: NewWorkpieceProcessClient(cfg), + ctx: ctx, + config: cfg, + Alert: NewAlertClient(cfg), + AlertRule: NewAlertRuleClient(cfg), + AssociationTrace: NewAssociationTraceClient(cfg), + Attachment: NewAttachmentClient(cfg), + DailyPlan: NewDailyPlanClient(cfg), + Dock: NewDockClient(cfg), + EventLog: NewEventLogClient(cfg), + FlowMaterial: NewFlowMaterialClient(cfg), + InspectionRecord: NewInspectionRecordClient(cfg), + LinePoint: NewLinePointClient(cfg), + Material: NewMaterialClient(cfg), + MaterialQtyReport: NewMaterialQtyReportClient(cfg), + MaterialRequest: NewMaterialRequestClient(cfg), + Permission: NewPermissionClient(cfg), + PlcSendLog: NewPlcSendLogClient(cfg), + ProcessFlow: NewProcessFlowClient(cfg), + ProcessStep: NewProcessStepClient(cfg), + ProductProcess: NewProductProcessClient(cfg), + ProductProcessItem: NewProductProcessItemClient(cfg), + Role: NewRoleClient(cfg), + SemiFlow: NewSemiFlowClient(cfg), + Station: NewStationClient(cfg), + StationState: NewStationStateClient(cfg), + StepCriterion: NewStepCriterionClient(cfg), + StepData: NewStepDataClient(cfg), + StepSignRecord: NewStepSignRecordClient(cfg), + SysConfig: NewSysConfigClient(cfg), + TorqueRecord: NewTorqueRecordClient(cfg), + User: NewUserClient(cfg), + UserStation: NewUserStationClient(cfg), + WorkOrder: NewWorkOrderClient(cfg), + Workpiece: NewWorkpieceClient(cfg), + WorkpieceBind: NewWorkpieceBindClient(cfg), + WorkpieceProcess: NewWorkpieceProcessClient(cfg), }, nil } @@ -302,40 +312,42 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) cfg := c.config cfg.driver = &txDriver{tx: tx, drv: c.driver} return &Tx{ - ctx: ctx, - config: cfg, - Alert: NewAlertClient(cfg), - AlertRule: NewAlertRuleClient(cfg), - AssociationTrace: NewAssociationTraceClient(cfg), - Attachment: NewAttachmentClient(cfg), - DailyPlan: NewDailyPlanClient(cfg), - Dock: NewDockClient(cfg), - EventLog: NewEventLogClient(cfg), - FlowMaterial: NewFlowMaterialClient(cfg), - InspectionRecord: NewInspectionRecordClient(cfg), - LinePoint: NewLinePointClient(cfg), - Material: NewMaterialClient(cfg), - MaterialQtyReport: NewMaterialQtyReportClient(cfg), - MaterialRequest: NewMaterialRequestClient(cfg), - Permission: NewPermissionClient(cfg), - PlcSendLog: NewPlcSendLogClient(cfg), - ProcessFlow: NewProcessFlowClient(cfg), - ProcessStep: NewProcessStepClient(cfg), - Role: NewRoleClient(cfg), - SemiFlow: NewSemiFlowClient(cfg), - Station: NewStationClient(cfg), - StationState: NewStationStateClient(cfg), - StepCriterion: NewStepCriterionClient(cfg), - StepData: NewStepDataClient(cfg), - StepSignRecord: NewStepSignRecordClient(cfg), - SysConfig: NewSysConfigClient(cfg), - TorqueRecord: NewTorqueRecordClient(cfg), - User: NewUserClient(cfg), - UserStation: NewUserStationClient(cfg), - WorkOrder: NewWorkOrderClient(cfg), - Workpiece: NewWorkpieceClient(cfg), - WorkpieceBind: NewWorkpieceBindClient(cfg), - WorkpieceProcess: NewWorkpieceProcessClient(cfg), + ctx: ctx, + config: cfg, + Alert: NewAlertClient(cfg), + AlertRule: NewAlertRuleClient(cfg), + AssociationTrace: NewAssociationTraceClient(cfg), + Attachment: NewAttachmentClient(cfg), + DailyPlan: NewDailyPlanClient(cfg), + Dock: NewDockClient(cfg), + EventLog: NewEventLogClient(cfg), + FlowMaterial: NewFlowMaterialClient(cfg), + InspectionRecord: NewInspectionRecordClient(cfg), + LinePoint: NewLinePointClient(cfg), + Material: NewMaterialClient(cfg), + MaterialQtyReport: NewMaterialQtyReportClient(cfg), + MaterialRequest: NewMaterialRequestClient(cfg), + Permission: NewPermissionClient(cfg), + PlcSendLog: NewPlcSendLogClient(cfg), + ProcessFlow: NewProcessFlowClient(cfg), + ProcessStep: NewProcessStepClient(cfg), + ProductProcess: NewProductProcessClient(cfg), + ProductProcessItem: NewProductProcessItemClient(cfg), + Role: NewRoleClient(cfg), + SemiFlow: NewSemiFlowClient(cfg), + Station: NewStationClient(cfg), + StationState: NewStationStateClient(cfg), + StepCriterion: NewStepCriterionClient(cfg), + StepData: NewStepDataClient(cfg), + StepSignRecord: NewStepSignRecordClient(cfg), + SysConfig: NewSysConfigClient(cfg), + TorqueRecord: NewTorqueRecordClient(cfg), + User: NewUserClient(cfg), + UserStation: NewUserStationClient(cfg), + WorkOrder: NewWorkOrderClient(cfg), + Workpiece: NewWorkpieceClient(cfg), + WorkpieceBind: NewWorkpieceBindClient(cfg), + WorkpieceProcess: NewWorkpieceProcessClient(cfg), }, nil } @@ -368,10 +380,10 @@ func (c *Client) Use(hooks ...Hook) { c.Alert, c.AlertRule, c.AssociationTrace, c.Attachment, c.DailyPlan, c.Dock, c.EventLog, c.FlowMaterial, c.InspectionRecord, c.LinePoint, c.Material, c.MaterialQtyReport, c.MaterialRequest, c.Permission, c.PlcSendLog, - c.ProcessFlow, c.ProcessStep, c.Role, c.SemiFlow, c.Station, c.StationState, - c.StepCriterion, c.StepData, c.StepSignRecord, c.SysConfig, c.TorqueRecord, - c.User, c.UserStation, c.WorkOrder, c.Workpiece, c.WorkpieceBind, - c.WorkpieceProcess, + c.ProcessFlow, c.ProcessStep, c.ProductProcess, c.ProductProcessItem, c.Role, + c.SemiFlow, c.Station, c.StationState, c.StepCriterion, c.StepData, + c.StepSignRecord, c.SysConfig, c.TorqueRecord, c.User, c.UserStation, + c.WorkOrder, c.Workpiece, c.WorkpieceBind, c.WorkpieceProcess, } { n.Use(hooks...) } @@ -384,10 +396,10 @@ func (c *Client) Intercept(interceptors ...Interceptor) { c.Alert, c.AlertRule, c.AssociationTrace, c.Attachment, c.DailyPlan, c.Dock, c.EventLog, c.FlowMaterial, c.InspectionRecord, c.LinePoint, c.Material, c.MaterialQtyReport, c.MaterialRequest, c.Permission, c.PlcSendLog, - c.ProcessFlow, c.ProcessStep, c.Role, c.SemiFlow, c.Station, c.StationState, - c.StepCriterion, c.StepData, c.StepSignRecord, c.SysConfig, c.TorqueRecord, - c.User, c.UserStation, c.WorkOrder, c.Workpiece, c.WorkpieceBind, - c.WorkpieceProcess, + c.ProcessFlow, c.ProcessStep, c.ProductProcess, c.ProductProcessItem, c.Role, + c.SemiFlow, c.Station, c.StationState, c.StepCriterion, c.StepData, + c.StepSignRecord, c.SysConfig, c.TorqueRecord, c.User, c.UserStation, + c.WorkOrder, c.Workpiece, c.WorkpieceBind, c.WorkpieceProcess, } { n.Intercept(interceptors...) } @@ -430,6 +442,10 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.ProcessFlow.mutate(ctx, m) case *ProcessStepMutation: return c.ProcessStep.mutate(ctx, m) + case *ProductProcessMutation: + return c.ProductProcess.mutate(ctx, m) + case *ProductProcessItemMutation: + return c.ProductProcessItem.mutate(ctx, m) case *RoleMutation: return c.Role.mutate(ctx, m) case *SemiFlowMutation: @@ -2726,6 +2742,272 @@ func (c *ProcessStepClient) mutate(ctx context.Context, m *ProcessStepMutation) } } +// ProductProcessClient is a client for the ProductProcess schema. +type ProductProcessClient struct { + config +} + +// NewProductProcessClient returns a client for the ProductProcess from the given config. +func NewProductProcessClient(c config) *ProductProcessClient { + return &ProductProcessClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `productprocess.Hooks(f(g(h())))`. +func (c *ProductProcessClient) Use(hooks ...Hook) { + c.hooks.ProductProcess = append(c.hooks.ProductProcess, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `productprocess.Intercept(f(g(h())))`. +func (c *ProductProcessClient) Intercept(interceptors ...Interceptor) { + c.inters.ProductProcess = append(c.inters.ProductProcess, interceptors...) +} + +// Create returns a builder for creating a ProductProcess entity. +func (c *ProductProcessClient) Create() *ProductProcessCreate { + mutation := newProductProcessMutation(c.config, OpCreate) + return &ProductProcessCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ProductProcess entities. +func (c *ProductProcessClient) CreateBulk(builders ...*ProductProcessCreate) *ProductProcessCreateBulk { + return &ProductProcessCreateBulk{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 *ProductProcessClient) MapCreateBulk(slice any, setFunc func(*ProductProcessCreate, int)) *ProductProcessCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ProductProcessCreateBulk{err: fmt.Errorf("calling to ProductProcessClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ProductProcessCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ProductProcessCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ProductProcess. +func (c *ProductProcessClient) Update() *ProductProcessUpdate { + mutation := newProductProcessMutation(c.config, OpUpdate) + return &ProductProcessUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ProductProcessClient) UpdateOne(_m *ProductProcess) *ProductProcessUpdateOne { + mutation := newProductProcessMutation(c.config, OpUpdateOne, withProductProcess(_m)) + return &ProductProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ProductProcessClient) UpdateOneID(id int) *ProductProcessUpdateOne { + mutation := newProductProcessMutation(c.config, OpUpdateOne, withProductProcessID(id)) + return &ProductProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ProductProcess. +func (c *ProductProcessClient) Delete() *ProductProcessDelete { + mutation := newProductProcessMutation(c.config, OpDelete) + return &ProductProcessDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ProductProcessClient) DeleteOne(_m *ProductProcess) *ProductProcessDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ProductProcessClient) DeleteOneID(id int) *ProductProcessDeleteOne { + builder := c.Delete().Where(productprocess.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ProductProcessDeleteOne{builder} +} + +// Query returns a query builder for ProductProcess. +func (c *ProductProcessClient) Query() *ProductProcessQuery { + return &ProductProcessQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeProductProcess}, + inters: c.Interceptors(), + } +} + +// Get returns a ProductProcess entity by its id. +func (c *ProductProcessClient) Get(ctx context.Context, id int) (*ProductProcess, error) { + return c.Query().Where(productprocess.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ProductProcessClient) GetX(ctx context.Context, id int) *ProductProcess { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *ProductProcessClient) Hooks() []Hook { + return c.hooks.ProductProcess +} + +// Interceptors returns the client interceptors. +func (c *ProductProcessClient) Interceptors() []Interceptor { + return c.inters.ProductProcess +} + +func (c *ProductProcessClient) mutate(ctx context.Context, m *ProductProcessMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ProductProcessCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ProductProcessUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ProductProcessUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ProductProcessDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ProductProcess mutation op: %q", m.Op()) + } +} + +// ProductProcessItemClient is a client for the ProductProcessItem schema. +type ProductProcessItemClient struct { + config +} + +// NewProductProcessItemClient returns a client for the ProductProcessItem from the given config. +func NewProductProcessItemClient(c config) *ProductProcessItemClient { + return &ProductProcessItemClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `productprocessitem.Hooks(f(g(h())))`. +func (c *ProductProcessItemClient) Use(hooks ...Hook) { + c.hooks.ProductProcessItem = append(c.hooks.ProductProcessItem, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `productprocessitem.Intercept(f(g(h())))`. +func (c *ProductProcessItemClient) Intercept(interceptors ...Interceptor) { + c.inters.ProductProcessItem = append(c.inters.ProductProcessItem, interceptors...) +} + +// Create returns a builder for creating a ProductProcessItem entity. +func (c *ProductProcessItemClient) Create() *ProductProcessItemCreate { + mutation := newProductProcessItemMutation(c.config, OpCreate) + return &ProductProcessItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ProductProcessItem entities. +func (c *ProductProcessItemClient) CreateBulk(builders ...*ProductProcessItemCreate) *ProductProcessItemCreateBulk { + return &ProductProcessItemCreateBulk{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 *ProductProcessItemClient) MapCreateBulk(slice any, setFunc func(*ProductProcessItemCreate, int)) *ProductProcessItemCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ProductProcessItemCreateBulk{err: fmt.Errorf("calling to ProductProcessItemClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ProductProcessItemCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ProductProcessItemCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ProductProcessItem. +func (c *ProductProcessItemClient) Update() *ProductProcessItemUpdate { + mutation := newProductProcessItemMutation(c.config, OpUpdate) + return &ProductProcessItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ProductProcessItemClient) UpdateOne(_m *ProductProcessItem) *ProductProcessItemUpdateOne { + mutation := newProductProcessItemMutation(c.config, OpUpdateOne, withProductProcessItem(_m)) + return &ProductProcessItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ProductProcessItemClient) UpdateOneID(id int) *ProductProcessItemUpdateOne { + mutation := newProductProcessItemMutation(c.config, OpUpdateOne, withProductProcessItemID(id)) + return &ProductProcessItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ProductProcessItem. +func (c *ProductProcessItemClient) Delete() *ProductProcessItemDelete { + mutation := newProductProcessItemMutation(c.config, OpDelete) + return &ProductProcessItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ProductProcessItemClient) DeleteOne(_m *ProductProcessItem) *ProductProcessItemDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ProductProcessItemClient) DeleteOneID(id int) *ProductProcessItemDeleteOne { + builder := c.Delete().Where(productprocessitem.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ProductProcessItemDeleteOne{builder} +} + +// Query returns a query builder for ProductProcessItem. +func (c *ProductProcessItemClient) Query() *ProductProcessItemQuery { + return &ProductProcessItemQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeProductProcessItem}, + inters: c.Interceptors(), + } +} + +// Get returns a ProductProcessItem entity by its id. +func (c *ProductProcessItemClient) Get(ctx context.Context, id int) (*ProductProcessItem, error) { + return c.Query().Where(productprocessitem.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ProductProcessItemClient) GetX(ctx context.Context, id int) *ProductProcessItem { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *ProductProcessItemClient) Hooks() []Hook { + return c.hooks.ProductProcessItem +} + +// Interceptors returns the client interceptors. +func (c *ProductProcessItemClient) Interceptors() []Interceptor { + return c.inters.ProductProcessItem +} + +func (c *ProductProcessItemClient) mutate(ctx context.Context, m *ProductProcessItemMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ProductProcessItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ProductProcessItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ProductProcessItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ProductProcessItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ProductProcessItem mutation op: %q", m.Op()) + } +} + // RoleClient is a client for the Role schema. type RoleClient struct { config @@ -4726,17 +5008,18 @@ type ( hooks struct { Alert, AlertRule, AssociationTrace, Attachment, DailyPlan, Dock, EventLog, FlowMaterial, InspectionRecord, LinePoint, Material, MaterialQtyReport, - MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, Role, - SemiFlow, Station, StationState, StepCriterion, StepData, StepSignRecord, - SysConfig, TorqueRecord, User, UserStation, WorkOrder, Workpiece, - WorkpieceBind, WorkpieceProcess []ent.Hook + MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, + ProductProcess, ProductProcessItem, Role, SemiFlow, Station, StationState, + StepCriterion, StepData, StepSignRecord, SysConfig, TorqueRecord, User, + UserStation, WorkOrder, Workpiece, WorkpieceBind, WorkpieceProcess []ent.Hook } inters struct { Alert, AlertRule, AssociationTrace, Attachment, DailyPlan, Dock, EventLog, FlowMaterial, InspectionRecord, LinePoint, Material, MaterialQtyReport, - MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, Role, - SemiFlow, Station, StationState, StepCriterion, StepData, StepSignRecord, - SysConfig, TorqueRecord, User, UserStation, WorkOrder, Workpiece, - WorkpieceBind, WorkpieceProcess []ent.Interceptor + MaterialRequest, Permission, PlcSendLog, ProcessFlow, ProcessStep, + ProductProcess, ProductProcessItem, Role, SemiFlow, Station, StationState, + StepCriterion, StepData, StepSignRecord, SysConfig, TorqueRecord, User, + UserStation, WorkOrder, Workpiece, WorkpieceBind, + WorkpieceProcess []ent.Interceptor } ) diff --git a/bj_power_mes/ent/ent.go b/bj_power_mes/ent/ent.go index f0590f2..31e55d0 100644 --- a/bj_power_mes/ent/ent.go +++ b/bj_power_mes/ent/ent.go @@ -20,6 +20,8 @@ import ( "bj_power_mes/ent/plcsendlog" "bj_power_mes/ent/processflow" "bj_power_mes/ent/processstep" + "bj_power_mes/ent/productprocess" + "bj_power_mes/ent/productprocessitem" "bj_power_mes/ent/role" "bj_power_mes/ent/semiflow" "bj_power_mes/ent/station" @@ -104,38 +106,40 @@ var ( func checkColumn(t, c string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ - alert.Table: alert.ValidColumn, - alertrule.Table: alertrule.ValidColumn, - associationtrace.Table: associationtrace.ValidColumn, - attachment.Table: attachment.ValidColumn, - dailyplan.Table: dailyplan.ValidColumn, - dock.Table: dock.ValidColumn, - eventlog.Table: eventlog.ValidColumn, - flowmaterial.Table: flowmaterial.ValidColumn, - inspectionrecord.Table: inspectionrecord.ValidColumn, - linepoint.Table: linepoint.ValidColumn, - material.Table: material.ValidColumn, - materialqtyreport.Table: materialqtyreport.ValidColumn, - materialrequest.Table: materialrequest.ValidColumn, - permission.Table: permission.ValidColumn, - plcsendlog.Table: plcsendlog.ValidColumn, - processflow.Table: processflow.ValidColumn, - processstep.Table: processstep.ValidColumn, - role.Table: role.ValidColumn, - semiflow.Table: semiflow.ValidColumn, - station.Table: station.ValidColumn, - stationstate.Table: stationstate.ValidColumn, - stepcriterion.Table: stepcriterion.ValidColumn, - stepdata.Table: stepdata.ValidColumn, - stepsignrecord.Table: stepsignrecord.ValidColumn, - sysconfig.Table: sysconfig.ValidColumn, - torquerecord.Table: torquerecord.ValidColumn, - user.Table: user.ValidColumn, - userstation.Table: userstation.ValidColumn, - workorder.Table: workorder.ValidColumn, - workpiece.Table: workpiece.ValidColumn, - workpiecebind.Table: workpiecebind.ValidColumn, - workpieceprocess.Table: workpieceprocess.ValidColumn, + alert.Table: alert.ValidColumn, + alertrule.Table: alertrule.ValidColumn, + associationtrace.Table: associationtrace.ValidColumn, + attachment.Table: attachment.ValidColumn, + dailyplan.Table: dailyplan.ValidColumn, + dock.Table: dock.ValidColumn, + eventlog.Table: eventlog.ValidColumn, + flowmaterial.Table: flowmaterial.ValidColumn, + inspectionrecord.Table: inspectionrecord.ValidColumn, + linepoint.Table: linepoint.ValidColumn, + material.Table: material.ValidColumn, + materialqtyreport.Table: materialqtyreport.ValidColumn, + materialrequest.Table: materialrequest.ValidColumn, + permission.Table: permission.ValidColumn, + plcsendlog.Table: plcsendlog.ValidColumn, + processflow.Table: processflow.ValidColumn, + processstep.Table: processstep.ValidColumn, + productprocess.Table: productprocess.ValidColumn, + productprocessitem.Table: productprocessitem.ValidColumn, + role.Table: role.ValidColumn, + semiflow.Table: semiflow.ValidColumn, + station.Table: station.ValidColumn, + stationstate.Table: stationstate.ValidColumn, + stepcriterion.Table: stepcriterion.ValidColumn, + stepdata.Table: stepdata.ValidColumn, + stepsignrecord.Table: stepsignrecord.ValidColumn, + sysconfig.Table: sysconfig.ValidColumn, + torquerecord.Table: torquerecord.ValidColumn, + user.Table: user.ValidColumn, + userstation.Table: userstation.ValidColumn, + workorder.Table: workorder.ValidColumn, + workpiece.Table: workpiece.ValidColumn, + workpiecebind.Table: workpiecebind.ValidColumn, + workpieceprocess.Table: workpieceprocess.ValidColumn, }) }) return columnCheck(t, c) diff --git a/bj_power_mes/ent/hook/hook.go b/bj_power_mes/ent/hook/hook.go index 24b1e5a..77b25d8 100644 --- a/bj_power_mes/ent/hook/hook.go +++ b/bj_power_mes/ent/hook/hook.go @@ -212,6 +212,30 @@ func (f ProcessStepFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ProcessStepMutation", m) } +// The ProductProcessFunc type is an adapter to allow the use of ordinary +// function as ProductProcess mutator. +type ProductProcessFunc func(context.Context, *ent.ProductProcessMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ProductProcessFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ProductProcessMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ProductProcessMutation", m) +} + +// The ProductProcessItemFunc type is an adapter to allow the use of ordinary +// function as ProductProcessItem mutator. +type ProductProcessItemFunc func(context.Context, *ent.ProductProcessItemMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ProductProcessItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ProductProcessItemMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ProductProcessItemMutation", m) +} + // The RoleFunc type is an adapter to allow the use of ordinary // function as Role mutator. type RoleFunc func(context.Context, *ent.RoleMutation) (ent.Value, error) diff --git a/bj_power_mes/ent/migrate/schema.go b/bj_power_mes/ent/migrate/schema.go index 40a7f44..63bc41c 100644 --- a/bj_power_mes/ent/migrate/schema.go +++ b/bj_power_mes/ent/migrate/schema.go @@ -621,6 +621,8 @@ var ( {Name: "need_check", Type: field.TypeBool, Comment: "是否需要检测确认(报工前须检验通过)", Default: false}, {Name: "need_operator_sign", Type: field.TypeBool, Comment: "是否需要操作工签字(报工前须签字确认)", Default: false}, {Name: "need_inspector_sign", Type: field.TypeBool, Comment: "是否需要检验员签字(审核通过并签字后放行)", Default: false}, + {Name: "need_audit", Type: field.TypeBool, Comment: "是否需要审核人复核签字(审核通过后放行)", Default: false}, + {Name: "audit_role", Type: field.TypeString, Nullable: true, Size: 64, Comment: "审核角色(如班组长/工艺员),具该角色的人员可签", Default: ""}, {Name: "attachment", Type: field.TypeJSON, Nullable: true, Comment: "本步骤图纸/附件列表 [{name,url}]", SchemaType: map[string]string{"postgres": "jsonb"}}, {Name: "remark", Type: field.TypeString, Size: 255, Default: ""}, {Name: "created_at", Type: field.TypeTime}, @@ -639,6 +641,63 @@ var ( }, }, } + // ProductProcessColumns holds the columns for the "product_process" table. + ProductProcessColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "product_code", Type: field.TypeString, Size: 64, Comment: "产品编码(WMS 物料档案 item_type=3 图号)"}, + {Name: "product_name", Type: field.TypeString, Size: 128, Comment: "产品名称(快照,WMS 改名不回写)", Default: ""}, + {Name: "name", Type: field.TypeString, Size: 128, Comment: "产品工艺名称,如 DX100常规"}, + {Name: "is_default", Type: field.TypeBool, Comment: "是否该产品的默认产品工艺(每产品至多一条)", Default: false}, + {Name: "status", Type: field.TypeString, Size: 20, Default: "ACTIVE"}, + {Name: "remark", Type: field.TypeString, Size: 255, Default: ""}, + {Name: "created_at", Type: field.TypeTime}, + } + // ProductProcessTable holds the schema information for the "product_process" table. + ProductProcessTable = &schema.Table{ + Name: "product_process", + Comment: "ProductProcess 产品工艺:产品级工艺定义(有序工艺集合,不绑工位;建工单时推导工位并复制为工艺组合快照)", + Columns: ProductProcessColumns, + PrimaryKey: []*schema.Column{ProductProcessColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "productprocess_product_code", + Unique: false, + Columns: []*schema.Column{ProductProcessColumns[1]}, + }, + { + Name: "productprocess_product_code_is_default", + Unique: false, + Columns: []*schema.Column{ProductProcessColumns[1], ProductProcessColumns[4]}, + }, + }, + } + // ProductProcessItemColumns holds the columns for the "product_process_item" table. + ProductProcessItemColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "product_process_id", Type: field.TypeInt, Comment: "所属产品工艺ID"}, + {Name: "seq", Type: field.TypeInt, Comment: "顺序号(从1严格递增,即执行顺序)"}, + {Name: "flow_id", Type: field.TypeInt, Comment: "工艺ID(process_flow)"}, + {Name: "created_at", Type: field.TypeTime}, + } + // ProductProcessItemTable holds the schema information for the "product_process_item" table. + ProductProcessItemTable = &schema.Table{ + Name: "product_process_item", + Comment: "ProductProcessItem 产品工艺明细:有序工艺执行点(seq 严格递增=串行;工位建单时推导,不落本表)", + Columns: ProductProcessItemColumns, + PrimaryKey: []*schema.Column{ProductProcessItemColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "productprocessitem_product_process_id", + Unique: false, + Columns: []*schema.Column{ProductProcessItemColumns[1]}, + }, + { + Name: "productprocessitem_product_process_id_flow_id", + Unique: true, + Columns: []*schema.Column{ProductProcessItemColumns[1], ProductProcessItemColumns[3]}, + }, + }, + } // RoleColumns holds the columns for the "role" table. RoleColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, @@ -1001,6 +1060,7 @@ var ( {Name: "created_by", Type: field.TypeString, Size: 64, Comment: "创建人", Default: ""}, {Name: "due_date", Type: field.TypeTime, Nullable: true, Comment: "完成日期(必填)"}, {Name: "flow_combination", Type: field.TypeJSON, Nullable: true, Comment: "工艺组合 [{flowId,stationNo}] 按工位号升序", SchemaType: map[string]string{"postgres": "jsonb"}}, + {Name: "product_process_id", Type: field.TypeInt, Comment: "来源产品工艺ID(0=无来源)", Default: 0}, {Name: "status", Type: field.TypeString, Size: 20, Default: "CREATED"}, {Name: "plan_start", Type: field.TypeTime, Nullable: true, Comment: "计划开始"}, {Name: "plan_end", Type: field.TypeTime, Nullable: true, Comment: "计划结束"}, @@ -1024,7 +1084,7 @@ var ( { Name: "workorder_status", Unique: false, - Columns: []*schema.Column{WorkOrderColumns[15]}, + Columns: []*schema.Column{WorkOrderColumns[16]}, }, { Name: "workorder_product_type_id", @@ -1192,6 +1252,8 @@ var ( PlcSendLogTable, ProcessFlowTable, ProcessStepTable, + ProductProcessTable, + ProductProcessItemTable, RoleTable, SemiFlowTable, StationTable, @@ -1262,6 +1324,12 @@ func init() { ProcessStepTable.Annotation = &entsql.Annotation{ Table: "process_step", } + ProductProcessTable.Annotation = &entsql.Annotation{ + Table: "product_process", + } + ProductProcessItemTable.Annotation = &entsql.Annotation{ + Table: "product_process_item", + } RoleTable.Annotation = &entsql.Annotation{ Table: "role", } diff --git a/bj_power_mes/ent/mutation.go b/bj_power_mes/ent/mutation.go index c0982aa..efabc73 100644 --- a/bj_power_mes/ent/mutation.go +++ b/bj_power_mes/ent/mutation.go @@ -21,6 +21,8 @@ import ( "bj_power_mes/ent/predicate" "bj_power_mes/ent/processflow" "bj_power_mes/ent/processstep" + "bj_power_mes/ent/productprocess" + "bj_power_mes/ent/productprocessitem" "bj_power_mes/ent/role" "bj_power_mes/ent/semiflow" "bj_power_mes/ent/station" @@ -55,38 +57,40 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. - TypeAlert = "Alert" - TypeAlertRule = "AlertRule" - TypeAssociationTrace = "AssociationTrace" - TypeAttachment = "Attachment" - TypeDailyPlan = "DailyPlan" - TypeDock = "Dock" - TypeEventLog = "EventLog" - TypeFlowMaterial = "FlowMaterial" - TypeInspectionRecord = "InspectionRecord" - TypeLinePoint = "LinePoint" - TypeMaterial = "Material" - TypeMaterialQtyReport = "MaterialQtyReport" - TypeMaterialRequest = "MaterialRequest" - TypePermission = "Permission" - TypePlcSendLog = "PlcSendLog" - TypeProcessFlow = "ProcessFlow" - TypeProcessStep = "ProcessStep" - TypeRole = "Role" - TypeSemiFlow = "SemiFlow" - TypeStation = "Station" - TypeStationState = "StationState" - TypeStepCriterion = "StepCriterion" - TypeStepData = "StepData" - TypeStepSignRecord = "StepSignRecord" - TypeSysConfig = "SysConfig" - TypeTorqueRecord = "TorqueRecord" - TypeUser = "User" - TypeUserStation = "UserStation" - TypeWorkOrder = "WorkOrder" - TypeWorkpiece = "Workpiece" - TypeWorkpieceBind = "WorkpieceBind" - TypeWorkpieceProcess = "WorkpieceProcess" + TypeAlert = "Alert" + TypeAlertRule = "AlertRule" + TypeAssociationTrace = "AssociationTrace" + TypeAttachment = "Attachment" + TypeDailyPlan = "DailyPlan" + TypeDock = "Dock" + TypeEventLog = "EventLog" + TypeFlowMaterial = "FlowMaterial" + TypeInspectionRecord = "InspectionRecord" + TypeLinePoint = "LinePoint" + TypeMaterial = "Material" + TypeMaterialQtyReport = "MaterialQtyReport" + TypeMaterialRequest = "MaterialRequest" + TypePermission = "Permission" + TypePlcSendLog = "PlcSendLog" + TypeProcessFlow = "ProcessFlow" + TypeProcessStep = "ProcessStep" + TypeProductProcess = "ProductProcess" + TypeProductProcessItem = "ProductProcessItem" + TypeRole = "Role" + TypeSemiFlow = "SemiFlow" + TypeStation = "Station" + TypeStationState = "StationState" + TypeStepCriterion = "StepCriterion" + TypeStepData = "StepData" + TypeStepSignRecord = "StepSignRecord" + TypeSysConfig = "SysConfig" + TypeTorqueRecord = "TorqueRecord" + TypeUser = "User" + TypeUserStation = "UserStation" + TypeWorkOrder = "WorkOrder" + TypeWorkpiece = "Workpiece" + TypeWorkpieceBind = "WorkpieceBind" + TypeWorkpieceProcess = "WorkpieceProcess" ) // AlertMutation represents an operation that mutates the Alert nodes in the graph. @@ -16599,6 +16603,8 @@ type ProcessStepMutation struct { needCheck *bool needOperatorSign *bool needInspectorSign *bool + needAudit *bool + auditRole *string attachment *[]map[string]string appendattachment []map[string]string remark *string @@ -17055,6 +17061,91 @@ func (m *ProcessStepMutation) ResetNeedInspectorSign() { m.needInspectorSign = nil } +// SetNeedAudit sets the "needAudit" field. +func (m *ProcessStepMutation) SetNeedAudit(b bool) { + m.needAudit = &b +} + +// NeedAudit returns the value of the "needAudit" field in the mutation. +func (m *ProcessStepMutation) NeedAudit() (r bool, exists bool) { + v := m.needAudit + if v == nil { + return + } + return *v, true +} + +// OldNeedAudit returns the old "needAudit" field's value of the ProcessStep entity. +// If the ProcessStep 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 *ProcessStepMutation) OldNeedAudit(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNeedAudit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNeedAudit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNeedAudit: %w", err) + } + return oldValue.NeedAudit, nil +} + +// ResetNeedAudit resets all changes to the "needAudit" field. +func (m *ProcessStepMutation) ResetNeedAudit() { + m.needAudit = nil +} + +// SetAuditRole sets the "auditRole" field. +func (m *ProcessStepMutation) SetAuditRole(s string) { + m.auditRole = &s +} + +// AuditRole returns the value of the "auditRole" field in the mutation. +func (m *ProcessStepMutation) AuditRole() (r string, exists bool) { + v := m.auditRole + if v == nil { + return + } + return *v, true +} + +// OldAuditRole returns the old "auditRole" field's value of the ProcessStep entity. +// If the ProcessStep 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 *ProcessStepMutation) OldAuditRole(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAuditRole is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAuditRole requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAuditRole: %w", err) + } + return oldValue.AuditRole, nil +} + +// ClearAuditRole clears the value of the "auditRole" field. +func (m *ProcessStepMutation) ClearAuditRole() { + m.auditRole = nil + m.clearedFields[processstep.FieldAuditRole] = struct{}{} +} + +// AuditRoleCleared returns if the "auditRole" field was cleared in this mutation. +func (m *ProcessStepMutation) AuditRoleCleared() bool { + _, ok := m.clearedFields[processstep.FieldAuditRole] + return ok +} + +// ResetAuditRole resets all changes to the "auditRole" field. +func (m *ProcessStepMutation) ResetAuditRole() { + m.auditRole = nil + delete(m.clearedFields, processstep.FieldAuditRole) +} + // SetAttachment sets the "attachment" field. func (m *ProcessStepMutation) SetAttachment(value []map[string]string) { m.attachment = &value @@ -17226,7 +17317,7 @@ func (m *ProcessStepMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ProcessStepMutation) Fields() []string { - fields := make([]string, 0, 11) + fields := make([]string, 0, 13) if m.flowId != nil { fields = append(fields, processstep.FieldFlowId) } @@ -17251,6 +17342,12 @@ func (m *ProcessStepMutation) Fields() []string { if m.needInspectorSign != nil { fields = append(fields, processstep.FieldNeedInspectorSign) } + if m.needAudit != nil { + fields = append(fields, processstep.FieldNeedAudit) + } + if m.auditRole != nil { + fields = append(fields, processstep.FieldAuditRole) + } if m.attachment != nil { fields = append(fields, processstep.FieldAttachment) } @@ -17284,6 +17381,10 @@ func (m *ProcessStepMutation) Field(name string) (ent.Value, bool) { return m.NeedOperatorSign() case processstep.FieldNeedInspectorSign: return m.NeedInspectorSign() + case processstep.FieldNeedAudit: + return m.NeedAudit() + case processstep.FieldAuditRole: + return m.AuditRole() case processstep.FieldAttachment: return m.Attachment() case processstep.FieldRemark: @@ -17315,6 +17416,10 @@ func (m *ProcessStepMutation) OldField(ctx context.Context, name string) (ent.Va return m.OldNeedOperatorSign(ctx) case processstep.FieldNeedInspectorSign: return m.OldNeedInspectorSign(ctx) + case processstep.FieldNeedAudit: + return m.OldNeedAudit(ctx) + case processstep.FieldAuditRole: + return m.OldAuditRole(ctx) case processstep.FieldAttachment: return m.OldAttachment(ctx) case processstep.FieldRemark: @@ -17386,6 +17491,20 @@ func (m *ProcessStepMutation) SetField(name string, value ent.Value) error { } m.SetNeedInspectorSign(v) return nil + case processstep.FieldNeedAudit: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNeedAudit(v) + return nil + case processstep.FieldAuditRole: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAuditRole(v) + return nil case processstep.FieldAttachment: v, ok := value.([]map[string]string) if !ok { @@ -17467,6 +17586,9 @@ func (m *ProcessStepMutation) ClearedFields() []string { if m.FieldCleared(processstep.FieldFlowId) { fields = append(fields, processstep.FieldFlowId) } + if m.FieldCleared(processstep.FieldAuditRole) { + fields = append(fields, processstep.FieldAuditRole) + } if m.FieldCleared(processstep.FieldAttachment) { fields = append(fields, processstep.FieldAttachment) } @@ -17487,6 +17609,9 @@ func (m *ProcessStepMutation) ClearField(name string) error { case processstep.FieldFlowId: m.ClearFlowId() return nil + case processstep.FieldAuditRole: + m.ClearAuditRole() + return nil case processstep.FieldAttachment: m.ClearAttachment() return nil @@ -17522,6 +17647,12 @@ func (m *ProcessStepMutation) ResetField(name string) error { case processstep.FieldNeedInspectorSign: m.ResetNeedInspectorSign() return nil + case processstep.FieldNeedAudit: + m.ResetNeedAudit() + return nil + case processstep.FieldAuditRole: + m.ResetAuditRole() + return nil case processstep.FieldAttachment: m.ResetAttachment() return nil @@ -17583,6 +17714,1258 @@ func (m *ProcessStepMutation) ResetEdge(name string) error { return fmt.Errorf("unknown ProcessStep edge %s", name) } +// ProductProcessMutation represents an operation that mutates the ProductProcess nodes in the graph. +type ProductProcessMutation struct { + config + op Op + typ string + id *int + productCode *string + productName *string + name *string + isDefault *bool + status *string + remark *string + createdAt *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*ProductProcess, error) + predicates []predicate.ProductProcess +} + +var _ ent.Mutation = (*ProductProcessMutation)(nil) + +// productprocessOption allows management of the mutation configuration using functional options. +type productprocessOption func(*ProductProcessMutation) + +// newProductProcessMutation creates new mutation for the ProductProcess entity. +func newProductProcessMutation(c config, op Op, opts ...productprocessOption) *ProductProcessMutation { + m := &ProductProcessMutation{ + config: c, + op: op, + typ: TypeProductProcess, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withProductProcessID sets the ID field of the mutation. +func withProductProcessID(id int) productprocessOption { + return func(m *ProductProcessMutation) { + var ( + err error + once sync.Once + value *ProductProcess + ) + m.oldValue = func(ctx context.Context) (*ProductProcess, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ProductProcess.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withProductProcess sets the old ProductProcess of the mutation. +func withProductProcess(node *ProductProcess) productprocessOption { + return func(m *ProductProcessMutation) { + m.oldValue = func(context.Context) (*ProductProcess, 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 ProductProcessMutation) 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 ProductProcessMutation) 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 ProductProcess entities. +func (m *ProductProcessMutation) 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 *ProductProcessMutation) 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 *ProductProcessMutation) 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().ProductProcess.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetProductCode sets the "productCode" field. +func (m *ProductProcessMutation) SetProductCode(s string) { + m.productCode = &s +} + +// ProductCode returns the value of the "productCode" field in the mutation. +func (m *ProductProcessMutation) ProductCode() (r string, exists bool) { + v := m.productCode + if v == nil { + return + } + return *v, true +} + +// OldProductCode returns the old "productCode" field's value of the ProductProcess entity. +// If the ProductProcess 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 *ProductProcessMutation) OldProductCode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProductCode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProductCode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProductCode: %w", err) + } + return oldValue.ProductCode, nil +} + +// ResetProductCode resets all changes to the "productCode" field. +func (m *ProductProcessMutation) ResetProductCode() { + m.productCode = nil +} + +// SetProductName sets the "productName" field. +func (m *ProductProcessMutation) SetProductName(s string) { + m.productName = &s +} + +// ProductName returns the value of the "productName" field in the mutation. +func (m *ProductProcessMutation) ProductName() (r string, exists bool) { + v := m.productName + if v == nil { + return + } + return *v, true +} + +// OldProductName returns the old "productName" field's value of the ProductProcess entity. +// If the ProductProcess 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 *ProductProcessMutation) OldProductName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProductName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProductName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProductName: %w", err) + } + return oldValue.ProductName, nil +} + +// ResetProductName resets all changes to the "productName" field. +func (m *ProductProcessMutation) ResetProductName() { + m.productName = nil +} + +// SetName sets the "name" field. +func (m *ProductProcessMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ProductProcessMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the ProductProcess entity. +// If the ProductProcess 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 *ProductProcessMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ProductProcessMutation) ResetName() { + m.name = nil +} + +// SetIsDefault sets the "isDefault" field. +func (m *ProductProcessMutation) SetIsDefault(b bool) { + m.isDefault = &b +} + +// IsDefault returns the value of the "isDefault" field in the mutation. +func (m *ProductProcessMutation) IsDefault() (r bool, exists bool) { + v := m.isDefault + if v == nil { + return + } + return *v, true +} + +// OldIsDefault returns the old "isDefault" field's value of the ProductProcess entity. +// If the ProductProcess 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 *ProductProcessMutation) OldIsDefault(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsDefault is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsDefault requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsDefault: %w", err) + } + return oldValue.IsDefault, nil +} + +// ResetIsDefault resets all changes to the "isDefault" field. +func (m *ProductProcessMutation) ResetIsDefault() { + m.isDefault = nil +} + +// SetStatus sets the "status" field. +func (m *ProductProcessMutation) SetStatus(s string) { + m.status = &s +} + +// Status returns the value of the "status" field in the mutation. +func (m *ProductProcessMutation) 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 ProductProcess entity. +// If the ProductProcess 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 *ProductProcessMutation) 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 *ProductProcessMutation) ResetStatus() { + m.status = nil +} + +// SetRemark sets the "remark" field. +func (m *ProductProcessMutation) SetRemark(s string) { + m.remark = &s +} + +// Remark returns the value of the "remark" field in the mutation. +func (m *ProductProcessMutation) Remark() (r string, exists bool) { + v := m.remark + if v == nil { + return + } + return *v, true +} + +// OldRemark returns the old "remark" field's value of the ProductProcess entity. +// If the ProductProcess 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 *ProductProcessMutation) OldRemark(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemark is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemark requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemark: %w", err) + } + return oldValue.Remark, nil +} + +// ResetRemark resets all changes to the "remark" field. +func (m *ProductProcessMutation) ResetRemark() { + m.remark = nil +} + +// SetCreatedAt sets the "createdAt" field. +func (m *ProductProcessMutation) SetCreatedAt(t time.Time) { + m.createdAt = &t +} + +// CreatedAt returns the value of the "createdAt" field in the mutation. +func (m *ProductProcessMutation) CreatedAt() (r time.Time, exists bool) { + v := m.createdAt + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "createdAt" field's value of the ProductProcess entity. +// If the ProductProcess 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 *ProductProcessMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "createdAt" field. +func (m *ProductProcessMutation) ResetCreatedAt() { + m.createdAt = nil +} + +// Where appends a list predicates to the ProductProcessMutation builder. +func (m *ProductProcessMutation) Where(ps ...predicate.ProductProcess) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ProductProcessMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ProductProcessMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProductProcess, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ProductProcessMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ProductProcessMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ProductProcess). +func (m *ProductProcessMutation) 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 *ProductProcessMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.productCode != nil { + fields = append(fields, productprocess.FieldProductCode) + } + if m.productName != nil { + fields = append(fields, productprocess.FieldProductName) + } + if m.name != nil { + fields = append(fields, productprocess.FieldName) + } + if m.isDefault != nil { + fields = append(fields, productprocess.FieldIsDefault) + } + if m.status != nil { + fields = append(fields, productprocess.FieldStatus) + } + if m.remark != nil { + fields = append(fields, productprocess.FieldRemark) + } + if m.createdAt != nil { + fields = append(fields, productprocess.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 *ProductProcessMutation) Field(name string) (ent.Value, bool) { + switch name { + case productprocess.FieldProductCode: + return m.ProductCode() + case productprocess.FieldProductName: + return m.ProductName() + case productprocess.FieldName: + return m.Name() + case productprocess.FieldIsDefault: + return m.IsDefault() + case productprocess.FieldStatus: + return m.Status() + case productprocess.FieldRemark: + return m.Remark() + case productprocess.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 *ProductProcessMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case productprocess.FieldProductCode: + return m.OldProductCode(ctx) + case productprocess.FieldProductName: + return m.OldProductName(ctx) + case productprocess.FieldName: + return m.OldName(ctx) + case productprocess.FieldIsDefault: + return m.OldIsDefault(ctx) + case productprocess.FieldStatus: + return m.OldStatus(ctx) + case productprocess.FieldRemark: + return m.OldRemark(ctx) + case productprocess.FieldCreatedAt: + return m.OldCreatedAt(ctx) + } + return nil, fmt.Errorf("unknown ProductProcess 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 *ProductProcessMutation) SetField(name string, value ent.Value) error { + switch name { + case productprocess.FieldProductCode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProductCode(v) + return nil + case productprocess.FieldProductName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProductName(v) + return nil + case productprocess.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case productprocess.FieldIsDefault: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsDefault(v) + return nil + case productprocess.FieldStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case productprocess.FieldRemark: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemark(v) + return nil + case productprocess.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown ProductProcess field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ProductProcessMutation) AddedFields() []string { + return nil +} + +// 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 *ProductProcessMutation) AddedField(name string) (ent.Value, bool) { + 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 *ProductProcessMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown ProductProcess numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ProductProcessMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ProductProcessMutation) 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 *ProductProcessMutation) ClearField(name string) error { + return fmt.Errorf("unknown ProductProcess 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 *ProductProcessMutation) ResetField(name string) error { + switch name { + case productprocess.FieldProductCode: + m.ResetProductCode() + return nil + case productprocess.FieldProductName: + m.ResetProductName() + return nil + case productprocess.FieldName: + m.ResetName() + return nil + case productprocess.FieldIsDefault: + m.ResetIsDefault() + return nil + case productprocess.FieldStatus: + m.ResetStatus() + return nil + case productprocess.FieldRemark: + m.ResetRemark() + return nil + case productprocess.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown ProductProcess field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ProductProcessMutation) 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 *ProductProcessMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ProductProcessMutation) 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 *ProductProcessMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ProductProcessMutation) 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 *ProductProcessMutation) 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 *ProductProcessMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown ProductProcess 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 *ProductProcessMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown ProductProcess edge %s", name) +} + +// ProductProcessItemMutation represents an operation that mutates the ProductProcessItem nodes in the graph. +type ProductProcessItemMutation struct { + config + op Op + typ string + id *int + productProcessId *int + addproductProcessId *int + seq *int + addseq *int + flowId *int + addflowId *int + createdAt *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*ProductProcessItem, error) + predicates []predicate.ProductProcessItem +} + +var _ ent.Mutation = (*ProductProcessItemMutation)(nil) + +// productprocessitemOption allows management of the mutation configuration using functional options. +type productprocessitemOption func(*ProductProcessItemMutation) + +// newProductProcessItemMutation creates new mutation for the ProductProcessItem entity. +func newProductProcessItemMutation(c config, op Op, opts ...productprocessitemOption) *ProductProcessItemMutation { + m := &ProductProcessItemMutation{ + config: c, + op: op, + typ: TypeProductProcessItem, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withProductProcessItemID sets the ID field of the mutation. +func withProductProcessItemID(id int) productprocessitemOption { + return func(m *ProductProcessItemMutation) { + var ( + err error + once sync.Once + value *ProductProcessItem + ) + m.oldValue = func(ctx context.Context) (*ProductProcessItem, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ProductProcessItem.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withProductProcessItem sets the old ProductProcessItem of the mutation. +func withProductProcessItem(node *ProductProcessItem) productprocessitemOption { + return func(m *ProductProcessItemMutation) { + m.oldValue = func(context.Context) (*ProductProcessItem, 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 ProductProcessItemMutation) 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 ProductProcessItemMutation) 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 ProductProcessItem entities. +func (m *ProductProcessItemMutation) 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 *ProductProcessItemMutation) 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 *ProductProcessItemMutation) 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().ProductProcessItem.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetProductProcessId sets the "productProcessId" field. +func (m *ProductProcessItemMutation) SetProductProcessId(i int) { + m.productProcessId = &i + m.addproductProcessId = nil +} + +// ProductProcessId returns the value of the "productProcessId" field in the mutation. +func (m *ProductProcessItemMutation) ProductProcessId() (r int, exists bool) { + v := m.productProcessId + if v == nil { + return + } + return *v, true +} + +// OldProductProcessId returns the old "productProcessId" field's value of the ProductProcessItem entity. +// If the ProductProcessItem 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 *ProductProcessItemMutation) OldProductProcessId(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProductProcessId is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProductProcessId requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProductProcessId: %w", err) + } + return oldValue.ProductProcessId, nil +} + +// AddProductProcessId adds i to the "productProcessId" field. +func (m *ProductProcessItemMutation) AddProductProcessId(i int) { + if m.addproductProcessId != nil { + *m.addproductProcessId += i + } else { + m.addproductProcessId = &i + } +} + +// AddedProductProcessId returns the value that was added to the "productProcessId" field in this mutation. +func (m *ProductProcessItemMutation) AddedProductProcessId() (r int, exists bool) { + v := m.addproductProcessId + if v == nil { + return + } + return *v, true +} + +// ResetProductProcessId resets all changes to the "productProcessId" field. +func (m *ProductProcessItemMutation) ResetProductProcessId() { + m.productProcessId = nil + m.addproductProcessId = nil +} + +// SetSeq sets the "seq" field. +func (m *ProductProcessItemMutation) SetSeq(i int) { + m.seq = &i + m.addseq = nil +} + +// Seq returns the value of the "seq" field in the mutation. +func (m *ProductProcessItemMutation) Seq() (r int, exists bool) { + v := m.seq + if v == nil { + return + } + return *v, true +} + +// OldSeq returns the old "seq" field's value of the ProductProcessItem entity. +// If the ProductProcessItem 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 *ProductProcessItemMutation) OldSeq(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSeq is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSeq requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSeq: %w", err) + } + return oldValue.Seq, nil +} + +// AddSeq adds i to the "seq" field. +func (m *ProductProcessItemMutation) AddSeq(i int) { + if m.addseq != nil { + *m.addseq += i + } else { + m.addseq = &i + } +} + +// AddedSeq returns the value that was added to the "seq" field in this mutation. +func (m *ProductProcessItemMutation) AddedSeq() (r int, exists bool) { + v := m.addseq + if v == nil { + return + } + return *v, true +} + +// ResetSeq resets all changes to the "seq" field. +func (m *ProductProcessItemMutation) ResetSeq() { + m.seq = nil + m.addseq = nil +} + +// SetFlowId sets the "flowId" field. +func (m *ProductProcessItemMutation) SetFlowId(i int) { + m.flowId = &i + m.addflowId = nil +} + +// FlowId returns the value of the "flowId" field in the mutation. +func (m *ProductProcessItemMutation) FlowId() (r int, exists bool) { + v := m.flowId + if v == nil { + return + } + return *v, true +} + +// OldFlowId returns the old "flowId" field's value of the ProductProcessItem entity. +// If the ProductProcessItem 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 *ProductProcessItemMutation) OldFlowId(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldFlowId is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldFlowId requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldFlowId: %w", err) + } + return oldValue.FlowId, nil +} + +// AddFlowId adds i to the "flowId" field. +func (m *ProductProcessItemMutation) AddFlowId(i int) { + if m.addflowId != nil { + *m.addflowId += i + } else { + m.addflowId = &i + } +} + +// AddedFlowId returns the value that was added to the "flowId" field in this mutation. +func (m *ProductProcessItemMutation) AddedFlowId() (r int, exists bool) { + v := m.addflowId + if v == nil { + return + } + return *v, true +} + +// ResetFlowId resets all changes to the "flowId" field. +func (m *ProductProcessItemMutation) ResetFlowId() { + m.flowId = nil + m.addflowId = nil +} + +// SetCreatedAt sets the "createdAt" field. +func (m *ProductProcessItemMutation) SetCreatedAt(t time.Time) { + m.createdAt = &t +} + +// CreatedAt returns the value of the "createdAt" field in the mutation. +func (m *ProductProcessItemMutation) CreatedAt() (r time.Time, exists bool) { + v := m.createdAt + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "createdAt" field's value of the ProductProcessItem entity. +// If the ProductProcessItem 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 *ProductProcessItemMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "createdAt" field. +func (m *ProductProcessItemMutation) ResetCreatedAt() { + m.createdAt = nil +} + +// Where appends a list predicates to the ProductProcessItemMutation builder. +func (m *ProductProcessItemMutation) Where(ps ...predicate.ProductProcessItem) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ProductProcessItemMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ProductProcessItemMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ProductProcessItem, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ProductProcessItemMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ProductProcessItemMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ProductProcessItem). +func (m *ProductProcessItemMutation) 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 *ProductProcessItemMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.productProcessId != nil { + fields = append(fields, productprocessitem.FieldProductProcessId) + } + if m.seq != nil { + fields = append(fields, productprocessitem.FieldSeq) + } + if m.flowId != nil { + fields = append(fields, productprocessitem.FieldFlowId) + } + if m.createdAt != nil { + fields = append(fields, productprocessitem.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 *ProductProcessItemMutation) Field(name string) (ent.Value, bool) { + switch name { + case productprocessitem.FieldProductProcessId: + return m.ProductProcessId() + case productprocessitem.FieldSeq: + return m.Seq() + case productprocessitem.FieldFlowId: + return m.FlowId() + case productprocessitem.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 *ProductProcessItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case productprocessitem.FieldProductProcessId: + return m.OldProductProcessId(ctx) + case productprocessitem.FieldSeq: + return m.OldSeq(ctx) + case productprocessitem.FieldFlowId: + return m.OldFlowId(ctx) + case productprocessitem.FieldCreatedAt: + return m.OldCreatedAt(ctx) + } + return nil, fmt.Errorf("unknown ProductProcessItem 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 *ProductProcessItemMutation) SetField(name string, value ent.Value) error { + switch name { + case productprocessitem.FieldProductProcessId: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProductProcessId(v) + return nil + case productprocessitem.FieldSeq: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSeq(v) + return nil + case productprocessitem.FieldFlowId: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetFlowId(v) + return nil + case productprocessitem.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown ProductProcessItem field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ProductProcessItemMutation) AddedFields() []string { + var fields []string + if m.addproductProcessId != nil { + fields = append(fields, productprocessitem.FieldProductProcessId) + } + if m.addseq != nil { + fields = append(fields, productprocessitem.FieldSeq) + } + if m.addflowId != nil { + fields = append(fields, productprocessitem.FieldFlowId) + } + 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 *ProductProcessItemMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case productprocessitem.FieldProductProcessId: + return m.AddedProductProcessId() + case productprocessitem.FieldSeq: + return m.AddedSeq() + case productprocessitem.FieldFlowId: + return m.AddedFlowId() + } + 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 *ProductProcessItemMutation) AddField(name string, value ent.Value) error { + switch name { + case productprocessitem.FieldProductProcessId: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddProductProcessId(v) + return nil + case productprocessitem.FieldSeq: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSeq(v) + return nil + case productprocessitem.FieldFlowId: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddFlowId(v) + return nil + } + return fmt.Errorf("unknown ProductProcessItem numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ProductProcessItemMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ProductProcessItemMutation) 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 *ProductProcessItemMutation) ClearField(name string) error { + return fmt.Errorf("unknown ProductProcessItem 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 *ProductProcessItemMutation) ResetField(name string) error { + switch name { + case productprocessitem.FieldProductProcessId: + m.ResetProductProcessId() + return nil + case productprocessitem.FieldSeq: + m.ResetSeq() + return nil + case productprocessitem.FieldFlowId: + m.ResetFlowId() + return nil + case productprocessitem.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown ProductProcessItem field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ProductProcessItemMutation) 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 *ProductProcessItemMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ProductProcessItemMutation) 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 *ProductProcessItemMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ProductProcessItemMutation) 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 *ProductProcessItemMutation) 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 *ProductProcessItemMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown ProductProcessItem 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 *ProductProcessItemMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown ProductProcessItem edge %s", name) +} + // RoleMutation represents an operation that mutates the Role nodes in the graph. type RoleMutation struct { config @@ -26856,6 +28239,8 @@ type WorkOrderMutation struct { dueDate *time.Time flowCombination *[]map[string]int appendflowCombination []map[string]int + productProcessId *int + addproductProcessId *int status *string planStart *time.Time planEnd *time.Time @@ -27599,6 +28984,62 @@ func (m *WorkOrderMutation) ResetFlowCombination() { delete(m.clearedFields, workorder.FieldFlowCombination) } +// SetProductProcessId sets the "productProcessId" field. +func (m *WorkOrderMutation) SetProductProcessId(i int) { + m.productProcessId = &i + m.addproductProcessId = nil +} + +// ProductProcessId returns the value of the "productProcessId" field in the mutation. +func (m *WorkOrderMutation) ProductProcessId() (r int, exists bool) { + v := m.productProcessId + if v == nil { + return + } + return *v, true +} + +// OldProductProcessId returns the old "productProcessId" field's value of the WorkOrder entity. +// If the WorkOrder 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 *WorkOrderMutation) OldProductProcessId(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProductProcessId is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProductProcessId requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProductProcessId: %w", err) + } + return oldValue.ProductProcessId, nil +} + +// AddProductProcessId adds i to the "productProcessId" field. +func (m *WorkOrderMutation) AddProductProcessId(i int) { + if m.addproductProcessId != nil { + *m.addproductProcessId += i + } else { + m.addproductProcessId = &i + } +} + +// AddedProductProcessId returns the value that was added to the "productProcessId" field in this mutation. +func (m *WorkOrderMutation) AddedProductProcessId() (r int, exists bool) { + v := m.addproductProcessId + if v == nil { + return + } + return *v, true +} + +// ResetProductProcessId resets all changes to the "productProcessId" field. +func (m *WorkOrderMutation) ResetProductProcessId() { + m.productProcessId = nil + m.addproductProcessId = nil +} + // SetStatus sets the "status" field. func (m *WorkOrderMutation) SetStatus(s string) { m.status = &s @@ -27950,7 +29391,7 @@ func (m *WorkOrderMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *WorkOrderMutation) Fields() []string { - fields := make([]string, 0, 21) + fields := make([]string, 0, 22) if m.workOrderNo != nil { fields = append(fields, workorder.FieldWorkOrderNo) } @@ -27993,6 +29434,9 @@ func (m *WorkOrderMutation) Fields() []string { if m.flowCombination != nil { fields = append(fields, workorder.FieldFlowCombination) } + if m.productProcessId != nil { + fields = append(fields, workorder.FieldProductProcessId) + } if m.status != nil { fields = append(fields, workorder.FieldStatus) } @@ -28050,6 +29494,8 @@ func (m *WorkOrderMutation) Field(name string) (ent.Value, bool) { return m.DueDate() case workorder.FieldFlowCombination: return m.FlowCombination() + case workorder.FieldProductProcessId: + return m.ProductProcessId() case workorder.FieldStatus: return m.Status() case workorder.FieldPlanStart: @@ -28101,6 +29547,8 @@ func (m *WorkOrderMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldDueDate(ctx) case workorder.FieldFlowCombination: return m.OldFlowCombination(ctx) + case workorder.FieldProductProcessId: + return m.OldProductProcessId(ctx) case workorder.FieldStatus: return m.OldStatus(ctx) case workorder.FieldPlanStart: @@ -28222,6 +29670,13 @@ func (m *WorkOrderMutation) SetField(name string, value ent.Value) error { } m.SetFlowCombination(v) return nil + case workorder.FieldProductProcessId: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProductProcessId(v) + return nil case workorder.FieldStatus: v, ok := value.(string) if !ok { @@ -28291,6 +29746,9 @@ func (m *WorkOrderMutation) AddedFields() []string { if m.addfailNum != nil { fields = append(fields, workorder.FieldFailNum) } + if m.addproductProcessId != nil { + fields = append(fields, workorder.FieldProductProcessId) + } return fields } @@ -28307,6 +29765,8 @@ func (m *WorkOrderMutation) AddedField(name string) (ent.Value, bool) { return m.AddedFinishedNum() case workorder.FieldFailNum: return m.AddedFailNum() + case workorder.FieldProductProcessId: + return m.AddedProductProcessId() } return nil, false } @@ -28344,6 +29804,13 @@ func (m *WorkOrderMutation) AddField(name string, value ent.Value) error { } m.AddFailNum(v) return nil + case workorder.FieldProductProcessId: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddProductProcessId(v) + return nil } return fmt.Errorf("unknown WorkOrder numeric field %s", name) } @@ -28458,6 +29925,9 @@ func (m *WorkOrderMutation) ResetField(name string) error { case workorder.FieldFlowCombination: m.ResetFlowCombination() return nil + case workorder.FieldProductProcessId: + m.ResetProductProcessId() + return nil case workorder.FieldStatus: m.ResetStatus() return nil diff --git a/bj_power_mes/ent/predicate/predicate.go b/bj_power_mes/ent/predicate/predicate.go index e950e92..5c1b73d 100644 --- a/bj_power_mes/ent/predicate/predicate.go +++ b/bj_power_mes/ent/predicate/predicate.go @@ -57,6 +57,12 @@ type ProcessFlow func(*sql.Selector) // ProcessStep is the predicate function for processstep builders. type ProcessStep func(*sql.Selector) +// ProductProcess is the predicate function for productprocess builders. +type ProductProcess func(*sql.Selector) + +// ProductProcessItem is the predicate function for productprocessitem builders. +type ProductProcessItem func(*sql.Selector) + // Role is the predicate function for role builders. type Role func(*sql.Selector) diff --git a/bj_power_mes/ent/processstep.go b/bj_power_mes/ent/processstep.go index 2e677ce..b81b0de 100644 --- a/bj_power_mes/ent/processstep.go +++ b/bj_power_mes/ent/processstep.go @@ -34,6 +34,10 @@ type ProcessStep struct { NeedOperatorSign bool `json:"needOperatorSign,omitempty"` // 是否需要检验员签字(审核通过并签字后放行) NeedInspectorSign bool `json:"needInspectorSign,omitempty"` + // 是否需要审核人复核签字(审核通过后放行) + NeedAudit bool `json:"needAudit,omitempty"` + // 审核角色(如班组长/工艺员),具该角色的人员可签 + AuditRole string `json:"auditRole,omitempty"` // 本步骤图纸/附件列表 [{name,url}] Attachment []map[string]string `json:"attachment,omitempty"` // Remark holds the value of the "remark" field. @@ -50,11 +54,11 @@ func (*ProcessStep) scanValues(columns []string) ([]any, error) { switch columns[i] { case processstep.FieldAttachment: values[i] = new([]byte) - case processstep.FieldIsTorque, processstep.FieldNeedCheck, processstep.FieldNeedOperatorSign, processstep.FieldNeedInspectorSign: + case processstep.FieldIsTorque, processstep.FieldNeedCheck, processstep.FieldNeedOperatorSign, processstep.FieldNeedInspectorSign, processstep.FieldNeedAudit: values[i] = new(sql.NullBool) case processstep.FieldID, processstep.FieldFlowId, processstep.FieldSeq: values[i] = new(sql.NullInt64) - case processstep.FieldName, processstep.FieldCollectType, processstep.FieldRemark: + case processstep.FieldName, processstep.FieldCollectType, processstep.FieldAuditRole, processstep.FieldRemark: values[i] = new(sql.NullString) case processstep.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -127,6 +131,18 @@ func (_m *ProcessStep) assignValues(columns []string, values []any) error { } else if value.Valid { _m.NeedInspectorSign = value.Bool } + case processstep.FieldNeedAudit: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field needAudit", values[i]) + } else if value.Valid { + _m.NeedAudit = value.Bool + } + case processstep.FieldAuditRole: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field auditRole", values[i]) + } else if value.Valid { + _m.AuditRole = value.String + } case processstep.FieldAttachment: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field attachment", values[i]) @@ -207,6 +223,12 @@ func (_m *ProcessStep) String() string { builder.WriteString("needInspectorSign=") builder.WriteString(fmt.Sprintf("%v", _m.NeedInspectorSign)) builder.WriteString(", ") + builder.WriteString("needAudit=") + builder.WriteString(fmt.Sprintf("%v", _m.NeedAudit)) + builder.WriteString(", ") + builder.WriteString("auditRole=") + builder.WriteString(_m.AuditRole) + builder.WriteString(", ") builder.WriteString("attachment=") builder.WriteString(fmt.Sprintf("%v", _m.Attachment)) builder.WriteString(", ") diff --git a/bj_power_mes/ent/processstep/processstep.go b/bj_power_mes/ent/processstep/processstep.go index 2427592..dc53ee5 100644 --- a/bj_power_mes/ent/processstep/processstep.go +++ b/bj_power_mes/ent/processstep/processstep.go @@ -29,6 +29,10 @@ const ( FieldNeedOperatorSign = "need_operator_sign" // FieldNeedInspectorSign holds the string denoting the needinspectorsign field in the database. FieldNeedInspectorSign = "need_inspector_sign" + // FieldNeedAudit holds the string denoting the needaudit field in the database. + FieldNeedAudit = "need_audit" + // FieldAuditRole holds the string denoting the auditrole field in the database. + FieldAuditRole = "audit_role" // FieldAttachment holds the string denoting the attachment field in the database. FieldAttachment = "attachment" // FieldRemark holds the string denoting the remark field in the database. @@ -50,6 +54,8 @@ var Columns = []string{ FieldNeedCheck, FieldNeedOperatorSign, FieldNeedInspectorSign, + FieldNeedAudit, + FieldAuditRole, FieldAttachment, FieldRemark, FieldCreatedAt, @@ -82,6 +88,12 @@ var ( DefaultNeedOperatorSign bool // DefaultNeedInspectorSign holds the default value on creation for the "needInspectorSign" field. DefaultNeedInspectorSign bool + // DefaultNeedAudit holds the default value on creation for the "needAudit" field. + DefaultNeedAudit bool + // DefaultAuditRole holds the default value on creation for the "auditRole" field. + DefaultAuditRole string + // AuditRoleValidator is a validator for the "auditRole" field. It is called by the builders before save. + AuditRoleValidator func(string) error // DefaultRemark holds the default value on creation for the "remark" field. DefaultRemark string // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. @@ -140,6 +152,16 @@ func ByNeedInspectorSign(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldNeedInspectorSign, opts...).ToFunc() } +// ByNeedAudit orders the results by the needAudit field. +func ByNeedAudit(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNeedAudit, opts...).ToFunc() +} + +// ByAuditRole orders the results by the auditRole field. +func ByAuditRole(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAuditRole, opts...).ToFunc() +} + // ByRemark orders the results by the remark field. func ByRemark(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldRemark, opts...).ToFunc() diff --git a/bj_power_mes/ent/processstep/where.go b/bj_power_mes/ent/processstep/where.go index ae3bc8e..d44a4b5 100644 --- a/bj_power_mes/ent/processstep/where.go +++ b/bj_power_mes/ent/processstep/where.go @@ -94,6 +94,16 @@ func NeedInspectorSign(v bool) predicate.ProcessStep { return predicate.ProcessStep(sql.FieldEQ(FieldNeedInspectorSign, v)) } +// NeedAudit applies equality check predicate on the "needAudit" field. It's identical to NeedAuditEQ. +func NeedAudit(v bool) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldEQ(FieldNeedAudit, v)) +} + +// AuditRole applies equality check predicate on the "auditRole" field. It's identical to AuditRoleEQ. +func AuditRole(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldEQ(FieldAuditRole, v)) +} + // Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. func Remark(v string) predicate.ProcessStep { return predicate.ProcessStep(sql.FieldEQ(FieldRemark, v)) @@ -364,6 +374,91 @@ func NeedInspectorSignNEQ(v bool) predicate.ProcessStep { return predicate.ProcessStep(sql.FieldNEQ(FieldNeedInspectorSign, v)) } +// NeedAuditEQ applies the EQ predicate on the "needAudit" field. +func NeedAuditEQ(v bool) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldEQ(FieldNeedAudit, v)) +} + +// NeedAuditNEQ applies the NEQ predicate on the "needAudit" field. +func NeedAuditNEQ(v bool) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldNEQ(FieldNeedAudit, v)) +} + +// AuditRoleEQ applies the EQ predicate on the "auditRole" field. +func AuditRoleEQ(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldEQ(FieldAuditRole, v)) +} + +// AuditRoleNEQ applies the NEQ predicate on the "auditRole" field. +func AuditRoleNEQ(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldNEQ(FieldAuditRole, v)) +} + +// AuditRoleIn applies the In predicate on the "auditRole" field. +func AuditRoleIn(vs ...string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldIn(FieldAuditRole, vs...)) +} + +// AuditRoleNotIn applies the NotIn predicate on the "auditRole" field. +func AuditRoleNotIn(vs ...string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldNotIn(FieldAuditRole, vs...)) +} + +// AuditRoleGT applies the GT predicate on the "auditRole" field. +func AuditRoleGT(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldGT(FieldAuditRole, v)) +} + +// AuditRoleGTE applies the GTE predicate on the "auditRole" field. +func AuditRoleGTE(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldGTE(FieldAuditRole, v)) +} + +// AuditRoleLT applies the LT predicate on the "auditRole" field. +func AuditRoleLT(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldLT(FieldAuditRole, v)) +} + +// AuditRoleLTE applies the LTE predicate on the "auditRole" field. +func AuditRoleLTE(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldLTE(FieldAuditRole, v)) +} + +// AuditRoleContains applies the Contains predicate on the "auditRole" field. +func AuditRoleContains(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldContains(FieldAuditRole, v)) +} + +// AuditRoleHasPrefix applies the HasPrefix predicate on the "auditRole" field. +func AuditRoleHasPrefix(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldHasPrefix(FieldAuditRole, v)) +} + +// AuditRoleHasSuffix applies the HasSuffix predicate on the "auditRole" field. +func AuditRoleHasSuffix(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldHasSuffix(FieldAuditRole, v)) +} + +// AuditRoleIsNil applies the IsNil predicate on the "auditRole" field. +func AuditRoleIsNil() predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldIsNull(FieldAuditRole)) +} + +// AuditRoleNotNil applies the NotNil predicate on the "auditRole" field. +func AuditRoleNotNil() predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldNotNull(FieldAuditRole)) +} + +// AuditRoleEqualFold applies the EqualFold predicate on the "auditRole" field. +func AuditRoleEqualFold(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldEqualFold(FieldAuditRole, v)) +} + +// AuditRoleContainsFold applies the ContainsFold predicate on the "auditRole" field. +func AuditRoleContainsFold(v string) predicate.ProcessStep { + return predicate.ProcessStep(sql.FieldContainsFold(FieldAuditRole, v)) +} + // AttachmentIsNil applies the IsNil predicate on the "attachment" field. func AttachmentIsNil() predicate.ProcessStep { return predicate.ProcessStep(sql.FieldIsNull(FieldAttachment)) diff --git a/bj_power_mes/ent/processstep_create.go b/bj_power_mes/ent/processstep_create.go index d85d22c..127c98c 100644 --- a/bj_power_mes/ent/processstep_create.go +++ b/bj_power_mes/ent/processstep_create.go @@ -124,6 +124,34 @@ func (_c *ProcessStepCreate) SetNillableNeedInspectorSign(v *bool) *ProcessStepC return _c } +// SetNeedAudit sets the "needAudit" field. +func (_c *ProcessStepCreate) SetNeedAudit(v bool) *ProcessStepCreate { + _c.mutation.SetNeedAudit(v) + return _c +} + +// SetNillableNeedAudit sets the "needAudit" field if the given value is not nil. +func (_c *ProcessStepCreate) SetNillableNeedAudit(v *bool) *ProcessStepCreate { + if v != nil { + _c.SetNeedAudit(*v) + } + return _c +} + +// SetAuditRole sets the "auditRole" field. +func (_c *ProcessStepCreate) SetAuditRole(v string) *ProcessStepCreate { + _c.mutation.SetAuditRole(v) + return _c +} + +// SetNillableAuditRole sets the "auditRole" field if the given value is not nil. +func (_c *ProcessStepCreate) SetNillableAuditRole(v *string) *ProcessStepCreate { + if v != nil { + _c.SetAuditRole(*v) + } + return _c +} + // SetAttachment sets the "attachment" field. func (_c *ProcessStepCreate) SetAttachment(v []map[string]string) *ProcessStepCreate { _c.mutation.SetAttachment(v) @@ -223,6 +251,14 @@ func (_c *ProcessStepCreate) defaults() { v := processstep.DefaultNeedInspectorSign _c.mutation.SetNeedInspectorSign(v) } + if _, ok := _c.mutation.NeedAudit(); !ok { + v := processstep.DefaultNeedAudit + _c.mutation.SetNeedAudit(v) + } + if _, ok := _c.mutation.AuditRole(); !ok { + v := processstep.DefaultAuditRole + _c.mutation.SetAuditRole(v) + } if _, ok := _c.mutation.Remark(); !ok { v := processstep.DefaultRemark _c.mutation.SetRemark(v) @@ -266,6 +302,14 @@ func (_c *ProcessStepCreate) check() error { if _, ok := _c.mutation.NeedInspectorSign(); !ok { return &ValidationError{Name: "needInspectorSign", err: errors.New(`ent: missing required field "ProcessStep.needInspectorSign"`)} } + if _, ok := _c.mutation.NeedAudit(); !ok { + return &ValidationError{Name: "needAudit", err: errors.New(`ent: missing required field "ProcessStep.needAudit"`)} + } + if v, ok := _c.mutation.AuditRole(); ok { + if err := processstep.AuditRoleValidator(v); err != nil { + return &ValidationError{Name: "auditRole", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.auditRole": %w`, err)} + } + } if _, ok := _c.mutation.Remark(); !ok { return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "ProcessStep.remark"`)} } @@ -346,6 +390,14 @@ func (_c *ProcessStepCreate) createSpec() (*ProcessStep, *sqlgraph.CreateSpec) { _spec.SetField(processstep.FieldNeedInspectorSign, field.TypeBool, value) _node.NeedInspectorSign = value } + if value, ok := _c.mutation.NeedAudit(); ok { + _spec.SetField(processstep.FieldNeedAudit, field.TypeBool, value) + _node.NeedAudit = value + } + if value, ok := _c.mutation.AuditRole(); ok { + _spec.SetField(processstep.FieldAuditRole, field.TypeString, value) + _node.AuditRole = value + } if value, ok := _c.mutation.Attachment(); ok { _spec.SetField(processstep.FieldAttachment, field.TypeJSON, value) _node.Attachment = value diff --git a/bj_power_mes/ent/processstep_update.go b/bj_power_mes/ent/processstep_update.go index 96ceb7b..c4c5eb6 100644 --- a/bj_power_mes/ent/processstep_update.go +++ b/bj_power_mes/ent/processstep_update.go @@ -161,6 +161,40 @@ func (_u *ProcessStepUpdate) SetNillableNeedInspectorSign(v *bool) *ProcessStepU return _u } +// SetNeedAudit sets the "needAudit" field. +func (_u *ProcessStepUpdate) SetNeedAudit(v bool) *ProcessStepUpdate { + _u.mutation.SetNeedAudit(v) + return _u +} + +// SetNillableNeedAudit sets the "needAudit" field if the given value is not nil. +func (_u *ProcessStepUpdate) SetNillableNeedAudit(v *bool) *ProcessStepUpdate { + if v != nil { + _u.SetNeedAudit(*v) + } + return _u +} + +// SetAuditRole sets the "auditRole" field. +func (_u *ProcessStepUpdate) SetAuditRole(v string) *ProcessStepUpdate { + _u.mutation.SetAuditRole(v) + return _u +} + +// SetNillableAuditRole sets the "auditRole" field if the given value is not nil. +func (_u *ProcessStepUpdate) SetNillableAuditRole(v *string) *ProcessStepUpdate { + if v != nil { + _u.SetAuditRole(*v) + } + return _u +} + +// ClearAuditRole clears the value of the "auditRole" field. +func (_u *ProcessStepUpdate) ClearAuditRole() *ProcessStepUpdate { + _u.mutation.ClearAuditRole() + return _u +} + // SetAttachment sets the "attachment" field. func (_u *ProcessStepUpdate) SetAttachment(v []map[string]string) *ProcessStepUpdate { _u.mutation.SetAttachment(v) @@ -237,6 +271,11 @@ func (_u *ProcessStepUpdate) check() error { return &ValidationError{Name: "collectType", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.collectType": %w`, err)} } } + if v, ok := _u.mutation.AuditRole(); ok { + if err := processstep.AuditRoleValidator(v); err != nil { + return &ValidationError{Name: "auditRole", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.auditRole": %w`, err)} + } + } if v, ok := _u.mutation.Remark(); ok { if err := processstep.RemarkValidator(v); err != nil { return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.remark": %w`, err)} @@ -296,6 +335,15 @@ func (_u *ProcessStepUpdate) sqlSave(ctx context.Context) (_node int, err error) if value, ok := _u.mutation.NeedInspectorSign(); ok { _spec.SetField(processstep.FieldNeedInspectorSign, field.TypeBool, value) } + if value, ok := _u.mutation.NeedAudit(); ok { + _spec.SetField(processstep.FieldNeedAudit, field.TypeBool, value) + } + if value, ok := _u.mutation.AuditRole(); ok { + _spec.SetField(processstep.FieldAuditRole, field.TypeString, value) + } + if _u.mutation.AuditRoleCleared() { + _spec.ClearField(processstep.FieldAuditRole, field.TypeString) + } if value, ok := _u.mutation.Attachment(); ok { _spec.SetField(processstep.FieldAttachment, field.TypeJSON, value) } @@ -464,6 +512,40 @@ func (_u *ProcessStepUpdateOne) SetNillableNeedInspectorSign(v *bool) *ProcessSt return _u } +// SetNeedAudit sets the "needAudit" field. +func (_u *ProcessStepUpdateOne) SetNeedAudit(v bool) *ProcessStepUpdateOne { + _u.mutation.SetNeedAudit(v) + return _u +} + +// SetNillableNeedAudit sets the "needAudit" field if the given value is not nil. +func (_u *ProcessStepUpdateOne) SetNillableNeedAudit(v *bool) *ProcessStepUpdateOne { + if v != nil { + _u.SetNeedAudit(*v) + } + return _u +} + +// SetAuditRole sets the "auditRole" field. +func (_u *ProcessStepUpdateOne) SetAuditRole(v string) *ProcessStepUpdateOne { + _u.mutation.SetAuditRole(v) + return _u +} + +// SetNillableAuditRole sets the "auditRole" field if the given value is not nil. +func (_u *ProcessStepUpdateOne) SetNillableAuditRole(v *string) *ProcessStepUpdateOne { + if v != nil { + _u.SetAuditRole(*v) + } + return _u +} + +// ClearAuditRole clears the value of the "auditRole" field. +func (_u *ProcessStepUpdateOne) ClearAuditRole() *ProcessStepUpdateOne { + _u.mutation.ClearAuditRole() + return _u +} + // SetAttachment sets the "attachment" field. func (_u *ProcessStepUpdateOne) SetAttachment(v []map[string]string) *ProcessStepUpdateOne { _u.mutation.SetAttachment(v) @@ -553,6 +635,11 @@ func (_u *ProcessStepUpdateOne) check() error { return &ValidationError{Name: "collectType", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.collectType": %w`, err)} } } + if v, ok := _u.mutation.AuditRole(); ok { + if err := processstep.AuditRoleValidator(v); err != nil { + return &ValidationError{Name: "auditRole", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.auditRole": %w`, err)} + } + } if v, ok := _u.mutation.Remark(); ok { if err := processstep.RemarkValidator(v); err != nil { return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.remark": %w`, err)} @@ -629,6 +716,15 @@ func (_u *ProcessStepUpdateOne) sqlSave(ctx context.Context) (_node *ProcessStep if value, ok := _u.mutation.NeedInspectorSign(); ok { _spec.SetField(processstep.FieldNeedInspectorSign, field.TypeBool, value) } + if value, ok := _u.mutation.NeedAudit(); ok { + _spec.SetField(processstep.FieldNeedAudit, field.TypeBool, value) + } + if value, ok := _u.mutation.AuditRole(); ok { + _spec.SetField(processstep.FieldAuditRole, field.TypeString, value) + } + if _u.mutation.AuditRoleCleared() { + _spec.ClearField(processstep.FieldAuditRole, field.TypeString) + } if value, ok := _u.mutation.Attachment(); ok { _spec.SetField(processstep.FieldAttachment, field.TypeJSON, value) } diff --git a/bj_power_mes/ent/productprocess.go b/bj_power_mes/ent/productprocess.go new file mode 100644 index 0000000..aa315f5 --- /dev/null +++ b/bj_power_mes/ent/productprocess.go @@ -0,0 +1,174 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/productprocess" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ProductProcess 产品工艺:产品级工艺定义(有序工艺集合,不绑工位;建工单时推导工位并复制为工艺组合快照) +type ProductProcess struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // 产品编码(WMS 物料档案 item_type=3 图号) + ProductCode string `json:"productCode,omitempty"` + // 产品名称(快照,WMS 改名不回写) + ProductName string `json:"productName,omitempty"` + // 产品工艺名称,如 DX100常规 + Name string `json:"name,omitempty"` + // 是否该产品的默认产品工艺(每产品至多一条) + IsDefault bool `json:"isDefault,omitempty"` + // Status holds the value of the "status" field. + Status string `json:"status,omitempty"` + // Remark holds the value of the "remark" field. + Remark string `json:"remark,omitempty"` + // CreatedAt holds the value of the "createdAt" field. + CreatedAt time.Time `json:"createdAt,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ProductProcess) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case productprocess.FieldIsDefault: + values[i] = new(sql.NullBool) + case productprocess.FieldID: + values[i] = new(sql.NullInt64) + case productprocess.FieldProductCode, productprocess.FieldProductName, productprocess.FieldName, productprocess.FieldStatus, productprocess.FieldRemark: + values[i] = new(sql.NullString) + case productprocess.FieldCreatedAt: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ProductProcess fields. +func (_m *ProductProcess) 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 productprocess.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 productprocess.FieldProductCode: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field productCode", values[i]) + } else if value.Valid { + _m.ProductCode = value.String + } + case productprocess.FieldProductName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field productName", values[i]) + } else if value.Valid { + _m.ProductName = value.String + } + case productprocess.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case productprocess.FieldIsDefault: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field isDefault", values[i]) + } else if value.Valid { + _m.IsDefault = value.Bool + } + case productprocess.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 productprocess.FieldRemark: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field remark", values[i]) + } else if value.Valid { + _m.Remark = value.String + } + case productprocess.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field createdAt", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ProductProcess. +// This includes values selected through modifiers, order, etc. +func (_m *ProductProcess) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this ProductProcess. +// Note that you need to call ProductProcess.Unwrap() before calling this method if this ProductProcess +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *ProductProcess) Update() *ProductProcessUpdateOne { + return NewProductProcessClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the ProductProcess 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 *ProductProcess) Unwrap() *ProductProcess { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: ProductProcess is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *ProductProcess) String() string { + var builder strings.Builder + builder.WriteString("ProductProcess(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("productCode=") + builder.WriteString(_m.ProductCode) + builder.WriteString(", ") + builder.WriteString("productName=") + builder.WriteString(_m.ProductName) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("isDefault=") + builder.WriteString(fmt.Sprintf("%v", _m.IsDefault)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(_m.Status) + builder.WriteString(", ") + builder.WriteString("remark=") + builder.WriteString(_m.Remark) + builder.WriteString(", ") + builder.WriteString("createdAt=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// ProductProcesses is a parsable slice of ProductProcess. +type ProductProcesses []*ProductProcess diff --git a/bj_power_mes/ent/productprocess/productprocess.go b/bj_power_mes/ent/productprocess/productprocess.go new file mode 100644 index 0000000..0762b5c --- /dev/null +++ b/bj_power_mes/ent/productprocess/productprocess.go @@ -0,0 +1,122 @@ +// Code generated by ent, DO NOT EDIT. + +package productprocess + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the productprocess type in the database. + Label = "product_process" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldProductCode holds the string denoting the productcode field in the database. + FieldProductCode = "product_code" + // FieldProductName holds the string denoting the productname field in the database. + FieldProductName = "product_name" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldIsDefault holds the string denoting the isdefault field in the database. + FieldIsDefault = "is_default" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldRemark holds the string denoting the remark field in the database. + FieldRemark = "remark" + // FieldCreatedAt holds the string denoting the createdat field in the database. + FieldCreatedAt = "created_at" + // Table holds the table name of the productprocess in the database. + Table = "product_process" +) + +// Columns holds all SQL columns for productprocess fields. +var Columns = []string{ + FieldID, + FieldProductCode, + FieldProductName, + FieldName, + FieldIsDefault, + FieldStatus, + FieldRemark, + 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 ( + // ProductCodeValidator is a validator for the "productCode" field. It is called by the builders before save. + ProductCodeValidator func(string) error + // DefaultProductName holds the default value on creation for the "productName" field. + DefaultProductName string + // ProductNameValidator is a validator for the "productName" field. It is called by the builders before save. + ProductNameValidator func(string) error + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultIsDefault holds the default value on creation for the "isDefault" field. + DefaultIsDefault bool + // 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 + // DefaultRemark holds the default value on creation for the "remark" field. + DefaultRemark string + // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. + RemarkValidator func(string) error + // DefaultCreatedAt holds the default value on creation for the "createdAt" field. + DefaultCreatedAt func() time.Time + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int) error +) + +// OrderOption defines the ordering options for the ProductProcess 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() +} + +// ByProductCode orders the results by the productCode field. +func ByProductCode(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProductCode, opts...).ToFunc() +} + +// ByProductName orders the results by the productName field. +func ByProductName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProductName, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByIsDefault orders the results by the isDefault field. +func ByIsDefault(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsDefault, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByRemark orders the results by the remark field. +func ByRemark(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRemark, 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/productprocess/where.go b/bj_power_mes/ent/productprocess/where.go new file mode 100644 index 0000000..56bfa8b --- /dev/null +++ b/bj_power_mes/ent/productprocess/where.go @@ -0,0 +1,480 @@ +// Code generated by ent, DO NOT EDIT. + +package productprocess + +import ( + "bj_power_mes/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLTE(FieldID, id)) +} + +// ProductCode applies equality check predicate on the "productCode" field. It's identical to ProductCodeEQ. +func ProductCode(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldProductCode, v)) +} + +// ProductName applies equality check predicate on the "productName" field. It's identical to ProductNameEQ. +func ProductName(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldProductName, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldName, v)) +} + +// IsDefault applies equality check predicate on the "isDefault" field. It's identical to IsDefaultEQ. +func IsDefault(v bool) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldIsDefault, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldStatus, v)) +} + +// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. +func Remark(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldRemark, v)) +} + +// CreatedAt applies equality check predicate on the "createdAt" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldCreatedAt, v)) +} + +// ProductCodeEQ applies the EQ predicate on the "productCode" field. +func ProductCodeEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldProductCode, v)) +} + +// ProductCodeNEQ applies the NEQ predicate on the "productCode" field. +func ProductCodeNEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldProductCode, v)) +} + +// ProductCodeIn applies the In predicate on the "productCode" field. +func ProductCodeIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldIn(FieldProductCode, vs...)) +} + +// ProductCodeNotIn applies the NotIn predicate on the "productCode" field. +func ProductCodeNotIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNotIn(FieldProductCode, vs...)) +} + +// ProductCodeGT applies the GT predicate on the "productCode" field. +func ProductCodeGT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGT(FieldProductCode, v)) +} + +// ProductCodeGTE applies the GTE predicate on the "productCode" field. +func ProductCodeGTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGTE(FieldProductCode, v)) +} + +// ProductCodeLT applies the LT predicate on the "productCode" field. +func ProductCodeLT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLT(FieldProductCode, v)) +} + +// ProductCodeLTE applies the LTE predicate on the "productCode" field. +func ProductCodeLTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLTE(FieldProductCode, v)) +} + +// ProductCodeContains applies the Contains predicate on the "productCode" field. +func ProductCodeContains(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContains(FieldProductCode, v)) +} + +// ProductCodeHasPrefix applies the HasPrefix predicate on the "productCode" field. +func ProductCodeHasPrefix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasPrefix(FieldProductCode, v)) +} + +// ProductCodeHasSuffix applies the HasSuffix predicate on the "productCode" field. +func ProductCodeHasSuffix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasSuffix(FieldProductCode, v)) +} + +// ProductCodeEqualFold applies the EqualFold predicate on the "productCode" field. +func ProductCodeEqualFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEqualFold(FieldProductCode, v)) +} + +// ProductCodeContainsFold applies the ContainsFold predicate on the "productCode" field. +func ProductCodeContainsFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContainsFold(FieldProductCode, v)) +} + +// ProductNameEQ applies the EQ predicate on the "productName" field. +func ProductNameEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldProductName, v)) +} + +// ProductNameNEQ applies the NEQ predicate on the "productName" field. +func ProductNameNEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldProductName, v)) +} + +// ProductNameIn applies the In predicate on the "productName" field. +func ProductNameIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldIn(FieldProductName, vs...)) +} + +// ProductNameNotIn applies the NotIn predicate on the "productName" field. +func ProductNameNotIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNotIn(FieldProductName, vs...)) +} + +// ProductNameGT applies the GT predicate on the "productName" field. +func ProductNameGT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGT(FieldProductName, v)) +} + +// ProductNameGTE applies the GTE predicate on the "productName" field. +func ProductNameGTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGTE(FieldProductName, v)) +} + +// ProductNameLT applies the LT predicate on the "productName" field. +func ProductNameLT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLT(FieldProductName, v)) +} + +// ProductNameLTE applies the LTE predicate on the "productName" field. +func ProductNameLTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLTE(FieldProductName, v)) +} + +// ProductNameContains applies the Contains predicate on the "productName" field. +func ProductNameContains(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContains(FieldProductName, v)) +} + +// ProductNameHasPrefix applies the HasPrefix predicate on the "productName" field. +func ProductNameHasPrefix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasPrefix(FieldProductName, v)) +} + +// ProductNameHasSuffix applies the HasSuffix predicate on the "productName" field. +func ProductNameHasSuffix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasSuffix(FieldProductName, v)) +} + +// ProductNameEqualFold applies the EqualFold predicate on the "productName" field. +func ProductNameEqualFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEqualFold(FieldProductName, v)) +} + +// ProductNameContainsFold applies the ContainsFold predicate on the "productName" field. +func ProductNameContainsFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContainsFold(FieldProductName, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContainsFold(FieldName, v)) +} + +// IsDefaultEQ applies the EQ predicate on the "isDefault" field. +func IsDefaultEQ(v bool) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldIsDefault, v)) +} + +// IsDefaultNEQ applies the NEQ predicate on the "isDefault" field. +func IsDefaultNEQ(v bool) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldIsDefault, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLTE(FieldStatus, v)) +} + +// StatusContains applies the Contains predicate on the "status" field. +func StatusContains(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContains(FieldStatus, v)) +} + +// StatusHasPrefix applies the HasPrefix predicate on the "status" field. +func StatusHasPrefix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasPrefix(FieldStatus, v)) +} + +// StatusHasSuffix applies the HasSuffix predicate on the "status" field. +func StatusHasSuffix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasSuffix(FieldStatus, v)) +} + +// StatusEqualFold applies the EqualFold predicate on the "status" field. +func StatusEqualFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEqualFold(FieldStatus, v)) +} + +// StatusContainsFold applies the ContainsFold predicate on the "status" field. +func StatusContainsFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContainsFold(FieldStatus, v)) +} + +// RemarkEQ applies the EQ predicate on the "remark" field. +func RemarkEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldRemark, v)) +} + +// RemarkNEQ applies the NEQ predicate on the "remark" field. +func RemarkNEQ(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldRemark, v)) +} + +// RemarkIn applies the In predicate on the "remark" field. +func RemarkIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldIn(FieldRemark, vs...)) +} + +// RemarkNotIn applies the NotIn predicate on the "remark" field. +func RemarkNotIn(vs ...string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNotIn(FieldRemark, vs...)) +} + +// RemarkGT applies the GT predicate on the "remark" field. +func RemarkGT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGT(FieldRemark, v)) +} + +// RemarkGTE applies the GTE predicate on the "remark" field. +func RemarkGTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGTE(FieldRemark, v)) +} + +// RemarkLT applies the LT predicate on the "remark" field. +func RemarkLT(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLT(FieldRemark, v)) +} + +// RemarkLTE applies the LTE predicate on the "remark" field. +func RemarkLTE(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLTE(FieldRemark, v)) +} + +// RemarkContains applies the Contains predicate on the "remark" field. +func RemarkContains(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContains(FieldRemark, v)) +} + +// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field. +func RemarkHasPrefix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasPrefix(FieldRemark, v)) +} + +// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field. +func RemarkHasSuffix(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldHasSuffix(FieldRemark, v)) +} + +// RemarkEqualFold applies the EqualFold predicate on the "remark" field. +func RemarkEqualFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEqualFold(FieldRemark, v)) +} + +// RemarkContainsFold applies the ContainsFold predicate on the "remark" field. +func RemarkContainsFold(v string) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldContainsFold(FieldRemark, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "createdAt" field. +func CreatedAtEQ(v time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "createdAt" field. +func CreatedAtNEQ(v time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "createdAt" field. +func CreatedAtIn(vs ...time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "createdAt" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "createdAt" field. +func CreatedAtGT(v time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "createdAt" field. +func CreatedAtGTE(v time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "createdAt" field. +func CreatedAtLT(v time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "createdAt" field. +func CreatedAtLTE(v time.Time) predicate.ProductProcess { + return predicate.ProductProcess(sql.FieldLTE(FieldCreatedAt, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ProductProcess) predicate.ProductProcess { + return predicate.ProductProcess(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ProductProcess) predicate.ProductProcess { + return predicate.ProductProcess(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ProductProcess) predicate.ProductProcess { + return predicate.ProductProcess(sql.NotPredicates(p)) +} diff --git a/bj_power_mes/ent/productprocess_create.go b/bj_power_mes/ent/productprocess_create.go new file mode 100644 index 0000000..e076208 --- /dev/null +++ b/bj_power_mes/ent/productprocess_create.go @@ -0,0 +1,370 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/productprocess" + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ProductProcessCreate is the builder for creating a ProductProcess entity. +type ProductProcessCreate struct { + config + mutation *ProductProcessMutation + hooks []Hook +} + +// SetProductCode sets the "productCode" field. +func (_c *ProductProcessCreate) SetProductCode(v string) *ProductProcessCreate { + _c.mutation.SetProductCode(v) + return _c +} + +// SetProductName sets the "productName" field. +func (_c *ProductProcessCreate) SetProductName(v string) *ProductProcessCreate { + _c.mutation.SetProductName(v) + return _c +} + +// SetNillableProductName sets the "productName" field if the given value is not nil. +func (_c *ProductProcessCreate) SetNillableProductName(v *string) *ProductProcessCreate { + if v != nil { + _c.SetProductName(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *ProductProcessCreate) SetName(v string) *ProductProcessCreate { + _c.mutation.SetName(v) + return _c +} + +// SetIsDefault sets the "isDefault" field. +func (_c *ProductProcessCreate) SetIsDefault(v bool) *ProductProcessCreate { + _c.mutation.SetIsDefault(v) + return _c +} + +// SetNillableIsDefault sets the "isDefault" field if the given value is not nil. +func (_c *ProductProcessCreate) SetNillableIsDefault(v *bool) *ProductProcessCreate { + if v != nil { + _c.SetIsDefault(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *ProductProcessCreate) SetStatus(v string) *ProductProcessCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *ProductProcessCreate) SetNillableStatus(v *string) *ProductProcessCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetRemark sets the "remark" field. +func (_c *ProductProcessCreate) SetRemark(v string) *ProductProcessCreate { + _c.mutation.SetRemark(v) + return _c +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_c *ProductProcessCreate) SetNillableRemark(v *string) *ProductProcessCreate { + if v != nil { + _c.SetRemark(*v) + } + return _c +} + +// SetCreatedAt sets the "createdAt" field. +func (_c *ProductProcessCreate) SetCreatedAt(v time.Time) *ProductProcessCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil. +func (_c *ProductProcessCreate) SetNillableCreatedAt(v *time.Time) *ProductProcessCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *ProductProcessCreate) SetID(v int) *ProductProcessCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the ProductProcessMutation object of the builder. +func (_c *ProductProcessCreate) Mutation() *ProductProcessMutation { + return _c.mutation +} + +// Save creates the ProductProcess in the database. +func (_c *ProductProcessCreate) Save(ctx context.Context) (*ProductProcess, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ProductProcessCreate) SaveX(ctx context.Context) *ProductProcess { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ProductProcessCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ProductProcessCreate) 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 *ProductProcessCreate) defaults() { + if _, ok := _c.mutation.ProductName(); !ok { + v := productprocess.DefaultProductName + _c.mutation.SetProductName(v) + } + if _, ok := _c.mutation.IsDefault(); !ok { + v := productprocess.DefaultIsDefault + _c.mutation.SetIsDefault(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := productprocess.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.Remark(); !ok { + v := productprocess.DefaultRemark + _c.mutation.SetRemark(v) + } + if _, ok := _c.mutation.CreatedAt(); !ok { + v := productprocess.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ProductProcessCreate) check() error { + if _, ok := _c.mutation.ProductCode(); !ok { + return &ValidationError{Name: "productCode", err: errors.New(`ent: missing required field "ProductProcess.productCode"`)} + } + if v, ok := _c.mutation.ProductCode(); ok { + if err := productprocess.ProductCodeValidator(v); err != nil { + return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.productCode": %w`, err)} + } + } + if _, ok := _c.mutation.ProductName(); !ok { + return &ValidationError{Name: "productName", err: errors.New(`ent: missing required field "ProductProcess.productName"`)} + } + if v, ok := _c.mutation.ProductName(); ok { + if err := productprocess.ProductNameValidator(v); err != nil { + return &ValidationError{Name: "productName", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.productName": %w`, err)} + } + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ProductProcess.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := productprocess.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.name": %w`, err)} + } + } + if _, ok := _c.mutation.IsDefault(); !ok { + return &ValidationError{Name: "isDefault", err: errors.New(`ent: missing required field "ProductProcess.isDefault"`)} + } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "ProductProcess.status"`)} + } + if v, ok := _c.mutation.Status(); ok { + if err := productprocess.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.status": %w`, err)} + } + } + if _, ok := _c.mutation.Remark(); !ok { + return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "ProductProcess.remark"`)} + } + if v, ok := _c.mutation.Remark(); ok { + if err := productprocess.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.remark": %w`, err)} + } + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "ProductProcess.createdAt"`)} + } + if v, ok := _c.mutation.ID(); ok { + if err := productprocess.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.id": %w`, err)} + } + } + return nil +} + +func (_c *ProductProcessCreate) sqlSave(ctx context.Context) (*ProductProcess, 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 *ProductProcessCreate) createSpec() (*ProductProcess, *sqlgraph.CreateSpec) { + var ( + _node = &ProductProcess{config: _c.config} + _spec = sqlgraph.NewCreateSpec(productprocess.Table, sqlgraph.NewFieldSpec(productprocess.FieldID, field.TypeInt)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.ProductCode(); ok { + _spec.SetField(productprocess.FieldProductCode, field.TypeString, value) + _node.ProductCode = value + } + if value, ok := _c.mutation.ProductName(); ok { + _spec.SetField(productprocess.FieldProductName, field.TypeString, value) + _node.ProductName = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(productprocess.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.IsDefault(); ok { + _spec.SetField(productprocess.FieldIsDefault, field.TypeBool, value) + _node.IsDefault = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(productprocess.FieldStatus, field.TypeString, value) + _node.Status = value + } + if value, ok := _c.mutation.Remark(); ok { + _spec.SetField(productprocess.FieldRemark, field.TypeString, value) + _node.Remark = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(productprocess.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + return _node, _spec +} + +// ProductProcessCreateBulk is the builder for creating many ProductProcess entities in bulk. +type ProductProcessCreateBulk struct { + config + err error + builders []*ProductProcessCreate +} + +// Save creates the ProductProcess entities in the database. +func (_c *ProductProcessCreateBulk) Save(ctx context.Context) ([]*ProductProcess, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*ProductProcess, 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.(*ProductProcessMutation) + 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 *ProductProcessCreateBulk) SaveX(ctx context.Context) []*ProductProcess { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ProductProcessCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ProductProcessCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/productprocess_delete.go b/bj_power_mes/ent/productprocess_delete.go new file mode 100644 index 0000000..6e21bd6 --- /dev/null +++ b/bj_power_mes/ent/productprocess_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/productprocess" + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ProductProcessDelete is the builder for deleting a ProductProcess entity. +type ProductProcessDelete struct { + config + hooks []Hook + mutation *ProductProcessMutation +} + +// Where appends a list predicates to the ProductProcessDelete builder. +func (_d *ProductProcessDelete) Where(ps ...predicate.ProductProcess) *ProductProcessDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ProductProcessDelete) 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 *ProductProcessDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ProductProcessDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(productprocess.Table, sqlgraph.NewFieldSpec(productprocess.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 +} + +// ProductProcessDeleteOne is the builder for deleting a single ProductProcess entity. +type ProductProcessDeleteOne struct { + _d *ProductProcessDelete +} + +// Where appends a list predicates to the ProductProcessDelete builder. +func (_d *ProductProcessDeleteOne) Where(ps ...predicate.ProductProcess) *ProductProcessDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ProductProcessDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{productprocess.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ProductProcessDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/productprocess_query.go b/bj_power_mes/ent/productprocess_query.go new file mode 100644 index 0000000..3f2fb50 --- /dev/null +++ b/bj_power_mes/ent/productprocess_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/productprocess" + "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" +) + +// ProductProcessQuery is the builder for querying ProductProcess entities. +type ProductProcessQuery struct { + config + ctx *QueryContext + order []productprocess.OrderOption + inters []Interceptor + predicates []predicate.ProductProcess + 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 ProductProcessQuery builder. +func (_q *ProductProcessQuery) Where(ps ...predicate.ProductProcess) *ProductProcessQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ProductProcessQuery) Limit(limit int) *ProductProcessQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ProductProcessQuery) Offset(offset int) *ProductProcessQuery { + _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 *ProductProcessQuery) Unique(unique bool) *ProductProcessQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ProductProcessQuery) Order(o ...productprocess.OrderOption) *ProductProcessQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first ProductProcess entity from the query. +// Returns a *NotFoundError when no ProductProcess was found. +func (_q *ProductProcessQuery) First(ctx context.Context) (*ProductProcess, 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{productprocess.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ProductProcessQuery) FirstX(ctx context.Context) *ProductProcess { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ProductProcess ID from the query. +// Returns a *NotFoundError when no ProductProcess ID was found. +func (_q *ProductProcessQuery) 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{productprocess.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ProductProcessQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ProductProcess entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ProductProcess entity is found. +// Returns a *NotFoundError when no ProductProcess entities are found. +func (_q *ProductProcessQuery) Only(ctx context.Context) (*ProductProcess, 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{productprocess.Label} + default: + return nil, &NotSingularError{productprocess.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ProductProcessQuery) OnlyX(ctx context.Context) *ProductProcess { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ProductProcess ID in the query. +// Returns a *NotSingularError when more than one ProductProcess ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ProductProcessQuery) 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{productprocess.Label} + default: + err = &NotSingularError{productprocess.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ProductProcessQuery) 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 ProductProcesses. +func (_q *ProductProcessQuery) All(ctx context.Context) ([]*ProductProcess, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ProductProcess, *ProductProcessQuery]() + return withInterceptors[[]*ProductProcess](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ProductProcessQuery) AllX(ctx context.Context) []*ProductProcess { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ProductProcess IDs. +func (_q *ProductProcessQuery) 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(productprocess.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ProductProcessQuery) 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 *ProductProcessQuery) 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[*ProductProcessQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ProductProcessQuery) 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 *ProductProcessQuery) 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 *ProductProcessQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ProductProcessQuery 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 *ProductProcessQuery) Clone() *ProductProcessQuery { + if _q == nil { + return nil + } + return &ProductProcessQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]productprocess.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.ProductProcess{}, _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 { +// ProductCode string `json:"productCode,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ProductProcess.Query(). +// GroupBy(productprocess.FieldProductCode). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ProductProcessQuery) GroupBy(field string, fields ...string) *ProductProcessGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ProductProcessGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = productprocess.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 { +// ProductCode string `json:"productCode,omitempty"` +// } +// +// client.ProductProcess.Query(). +// Select(productprocess.FieldProductCode). +// Scan(ctx, &v) +func (_q *ProductProcessQuery) Select(fields ...string) *ProductProcessSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ProductProcessSelect{ProductProcessQuery: _q} + sbuild.label = productprocess.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ProductProcessSelect configured with the given aggregations. +func (_q *ProductProcessQuery) Aggregate(fns ...AggregateFunc) *ProductProcessSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ProductProcessQuery) 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 !productprocess.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 *ProductProcessQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ProductProcess, error) { + var ( + nodes = []*ProductProcess{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ProductProcess).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ProductProcess{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 *ProductProcessQuery) 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 *ProductProcessQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(productprocess.Table, productprocess.Columns, sqlgraph.NewFieldSpec(productprocess.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, productprocess.FieldID) + for i := range fields { + if fields[i] != productprocess.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 *ProductProcessQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(productprocess.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = productprocess.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 *ProductProcessQuery) ForUpdate(opts ...sql.LockOption) *ProductProcessQuery { + 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 *ProductProcessQuery) ForShare(opts ...sql.LockOption) *ProductProcessQuery { + 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 *ProductProcessQuery) Modify(modifiers ...func(s *sql.Selector)) *ProductProcessSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// ProductProcessGroupBy is the group-by builder for ProductProcess entities. +type ProductProcessGroupBy struct { + selector + build *ProductProcessQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ProductProcessGroupBy) Aggregate(fns ...AggregateFunc) *ProductProcessGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ProductProcessGroupBy) 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[*ProductProcessQuery, *ProductProcessGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ProductProcessGroupBy) sqlScan(ctx context.Context, root *ProductProcessQuery, 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) +} + +// ProductProcessSelect is the builder for selecting fields of ProductProcess entities. +type ProductProcessSelect struct { + *ProductProcessQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ProductProcessSelect) Aggregate(fns ...AggregateFunc) *ProductProcessSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ProductProcessSelect) 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[*ProductProcessQuery, *ProductProcessSelect](ctx, _s.ProductProcessQuery, _s, _s.inters, v) +} + +func (_s *ProductProcessSelect) sqlScan(ctx context.Context, root *ProductProcessQuery, 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 *ProductProcessSelect) Modify(modifiers ...func(s *sql.Selector)) *ProductProcessSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/bj_power_mes/ent/productprocess_update.go b/bj_power_mes/ent/productprocess_update.go new file mode 100644 index 0000000..94cd11f --- /dev/null +++ b/bj_power_mes/ent/productprocess_update.go @@ -0,0 +1,461 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/predicate" + "bj_power_mes/ent/productprocess" + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ProductProcessUpdate is the builder for updating ProductProcess entities. +type ProductProcessUpdate struct { + config + hooks []Hook + mutation *ProductProcessMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ProductProcessUpdate builder. +func (_u *ProductProcessUpdate) Where(ps ...predicate.ProductProcess) *ProductProcessUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetProductCode sets the "productCode" field. +func (_u *ProductProcessUpdate) SetProductCode(v string) *ProductProcessUpdate { + _u.mutation.SetProductCode(v) + return _u +} + +// SetNillableProductCode sets the "productCode" field if the given value is not nil. +func (_u *ProductProcessUpdate) SetNillableProductCode(v *string) *ProductProcessUpdate { + if v != nil { + _u.SetProductCode(*v) + } + return _u +} + +// SetProductName sets the "productName" field. +func (_u *ProductProcessUpdate) SetProductName(v string) *ProductProcessUpdate { + _u.mutation.SetProductName(v) + return _u +} + +// SetNillableProductName sets the "productName" field if the given value is not nil. +func (_u *ProductProcessUpdate) SetNillableProductName(v *string) *ProductProcessUpdate { + if v != nil { + _u.SetProductName(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *ProductProcessUpdate) SetName(v string) *ProductProcessUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ProductProcessUpdate) SetNillableName(v *string) *ProductProcessUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetIsDefault sets the "isDefault" field. +func (_u *ProductProcessUpdate) SetIsDefault(v bool) *ProductProcessUpdate { + _u.mutation.SetIsDefault(v) + return _u +} + +// SetNillableIsDefault sets the "isDefault" field if the given value is not nil. +func (_u *ProductProcessUpdate) SetNillableIsDefault(v *bool) *ProductProcessUpdate { + if v != nil { + _u.SetIsDefault(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *ProductProcessUpdate) SetStatus(v string) *ProductProcessUpdate { + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ProductProcessUpdate) SetNillableStatus(v *string) *ProductProcessUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// SetRemark sets the "remark" field. +func (_u *ProductProcessUpdate) SetRemark(v string) *ProductProcessUpdate { + _u.mutation.SetRemark(v) + return _u +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_u *ProductProcessUpdate) SetNillableRemark(v *string) *ProductProcessUpdate { + if v != nil { + _u.SetRemark(*v) + } + return _u +} + +// Mutation returns the ProductProcessMutation object of the builder. +func (_u *ProductProcessUpdate) Mutation() *ProductProcessMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ProductProcessUpdate) 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 *ProductProcessUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ProductProcessUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ProductProcessUpdate) 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 *ProductProcessUpdate) check() error { + if v, ok := _u.mutation.ProductCode(); ok { + if err := productprocess.ProductCodeValidator(v); err != nil { + return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.productCode": %w`, err)} + } + } + if v, ok := _u.mutation.ProductName(); ok { + if err := productprocess.ProductNameValidator(v); err != nil { + return &ValidationError{Name: "productName", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.productName": %w`, err)} + } + } + if v, ok := _u.mutation.Name(); ok { + if err := productprocess.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.name": %w`, err)} + } + } + if v, ok := _u.mutation.Status(); ok { + if err := productprocess.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.status": %w`, err)} + } + } + if v, ok := _u.mutation.Remark(); ok { + if err := productprocess.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.remark": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ProductProcessUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProductProcessUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ProductProcessUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(productprocess.Table, productprocess.Columns, sqlgraph.NewFieldSpec(productprocess.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.ProductCode(); ok { + _spec.SetField(productprocess.FieldProductCode, field.TypeString, value) + } + if value, ok := _u.mutation.ProductName(); ok { + _spec.SetField(productprocess.FieldProductName, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(productprocess.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.IsDefault(); ok { + _spec.SetField(productprocess.FieldIsDefault, field.TypeBool, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(productprocess.FieldStatus, field.TypeString, value) + } + if value, ok := _u.mutation.Remark(); ok { + _spec.SetField(productprocess.FieldRemark, field.TypeString, value) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{productprocess.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ProductProcessUpdateOne is the builder for updating a single ProductProcess entity. +type ProductProcessUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ProductProcessMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetProductCode sets the "productCode" field. +func (_u *ProductProcessUpdateOne) SetProductCode(v string) *ProductProcessUpdateOne { + _u.mutation.SetProductCode(v) + return _u +} + +// SetNillableProductCode sets the "productCode" field if the given value is not nil. +func (_u *ProductProcessUpdateOne) SetNillableProductCode(v *string) *ProductProcessUpdateOne { + if v != nil { + _u.SetProductCode(*v) + } + return _u +} + +// SetProductName sets the "productName" field. +func (_u *ProductProcessUpdateOne) SetProductName(v string) *ProductProcessUpdateOne { + _u.mutation.SetProductName(v) + return _u +} + +// SetNillableProductName sets the "productName" field if the given value is not nil. +func (_u *ProductProcessUpdateOne) SetNillableProductName(v *string) *ProductProcessUpdateOne { + if v != nil { + _u.SetProductName(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *ProductProcessUpdateOne) SetName(v string) *ProductProcessUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ProductProcessUpdateOne) SetNillableName(v *string) *ProductProcessUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetIsDefault sets the "isDefault" field. +func (_u *ProductProcessUpdateOne) SetIsDefault(v bool) *ProductProcessUpdateOne { + _u.mutation.SetIsDefault(v) + return _u +} + +// SetNillableIsDefault sets the "isDefault" field if the given value is not nil. +func (_u *ProductProcessUpdateOne) SetNillableIsDefault(v *bool) *ProductProcessUpdateOne { + if v != nil { + _u.SetIsDefault(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *ProductProcessUpdateOne) SetStatus(v string) *ProductProcessUpdateOne { + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ProductProcessUpdateOne) SetNillableStatus(v *string) *ProductProcessUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// SetRemark sets the "remark" field. +func (_u *ProductProcessUpdateOne) SetRemark(v string) *ProductProcessUpdateOne { + _u.mutation.SetRemark(v) + return _u +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_u *ProductProcessUpdateOne) SetNillableRemark(v *string) *ProductProcessUpdateOne { + if v != nil { + _u.SetRemark(*v) + } + return _u +} + +// Mutation returns the ProductProcessMutation object of the builder. +func (_u *ProductProcessUpdateOne) Mutation() *ProductProcessMutation { + return _u.mutation +} + +// Where appends a list predicates to the ProductProcessUpdate builder. +func (_u *ProductProcessUpdateOne) Where(ps ...predicate.ProductProcess) *ProductProcessUpdateOne { + _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 *ProductProcessUpdateOne) Select(field string, fields ...string) *ProductProcessUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated ProductProcess entity. +func (_u *ProductProcessUpdateOne) Save(ctx context.Context) (*ProductProcess, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ProductProcessUpdateOne) SaveX(ctx context.Context) *ProductProcess { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ProductProcessUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ProductProcessUpdateOne) 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 *ProductProcessUpdateOne) check() error { + if v, ok := _u.mutation.ProductCode(); ok { + if err := productprocess.ProductCodeValidator(v); err != nil { + return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.productCode": %w`, err)} + } + } + if v, ok := _u.mutation.ProductName(); ok { + if err := productprocess.ProductNameValidator(v); err != nil { + return &ValidationError{Name: "productName", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.productName": %w`, err)} + } + } + if v, ok := _u.mutation.Name(); ok { + if err := productprocess.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.name": %w`, err)} + } + } + if v, ok := _u.mutation.Status(); ok { + if err := productprocess.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.status": %w`, err)} + } + } + if v, ok := _u.mutation.Remark(); ok { + if err := productprocess.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProductProcess.remark": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ProductProcessUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProductProcessUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ProductProcessUpdateOne) sqlSave(ctx context.Context) (_node *ProductProcess, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(productprocess.Table, productprocess.Columns, sqlgraph.NewFieldSpec(productprocess.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ProductProcess.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, productprocess.FieldID) + for _, f := range fields { + if !productprocess.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != productprocess.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.ProductCode(); ok { + _spec.SetField(productprocess.FieldProductCode, field.TypeString, value) + } + if value, ok := _u.mutation.ProductName(); ok { + _spec.SetField(productprocess.FieldProductName, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(productprocess.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.IsDefault(); ok { + _spec.SetField(productprocess.FieldIsDefault, field.TypeBool, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(productprocess.FieldStatus, field.TypeString, value) + } + if value, ok := _u.mutation.Remark(); ok { + _spec.SetField(productprocess.FieldRemark, field.TypeString, value) + } + _spec.AddModifiers(_u.modifiers...) + _node = &ProductProcess{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{productprocess.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/productprocessitem.go b/bj_power_mes/ent/productprocessitem.go new file mode 100644 index 0000000..4e01829 --- /dev/null +++ b/bj_power_mes/ent/productprocessitem.go @@ -0,0 +1,137 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/productprocessitem" + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// ProductProcessItem 产品工艺明细:有序工艺执行点(seq 严格递增=串行;工位建单时推导,不落本表) +type ProductProcessItem struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // 所属产品工艺ID + ProductProcessId int `json:"productProcessId,omitempty"` + // 顺序号(从1严格递增,即执行顺序) + Seq int `json:"seq,omitempty"` + // 工艺ID(process_flow) + FlowId int `json:"flowId,omitempty"` + // CreatedAt holds the value of the "createdAt" field. + CreatedAt time.Time `json:"createdAt,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ProductProcessItem) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case productprocessitem.FieldID, productprocessitem.FieldProductProcessId, productprocessitem.FieldSeq, productprocessitem.FieldFlowId: + values[i] = new(sql.NullInt64) + case productprocessitem.FieldCreatedAt: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ProductProcessItem fields. +func (_m *ProductProcessItem) 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 productprocessitem.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 productprocessitem.FieldProductProcessId: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field productProcessId", values[i]) + } else if value.Valid { + _m.ProductProcessId = int(value.Int64) + } + case productprocessitem.FieldSeq: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field seq", values[i]) + } else if value.Valid { + _m.Seq = int(value.Int64) + } + case productprocessitem.FieldFlowId: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field flowId", values[i]) + } else if value.Valid { + _m.FlowId = int(value.Int64) + } + case productprocessitem.FieldCreatedAt: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field createdAt", values[i]) + } else if value.Valid { + _m.CreatedAt = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ProductProcessItem. +// This includes values selected through modifiers, order, etc. +func (_m *ProductProcessItem) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// Update returns a builder for updating this ProductProcessItem. +// Note that you need to call ProductProcessItem.Unwrap() before calling this method if this ProductProcessItem +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *ProductProcessItem) Update() *ProductProcessItemUpdateOne { + return NewProductProcessItemClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the ProductProcessItem 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 *ProductProcessItem) Unwrap() *ProductProcessItem { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: ProductProcessItem is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *ProductProcessItem) String() string { + var builder strings.Builder + builder.WriteString("ProductProcessItem(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("productProcessId=") + builder.WriteString(fmt.Sprintf("%v", _m.ProductProcessId)) + builder.WriteString(", ") + builder.WriteString("seq=") + builder.WriteString(fmt.Sprintf("%v", _m.Seq)) + builder.WriteString(", ") + builder.WriteString("flowId=") + builder.WriteString(fmt.Sprintf("%v", _m.FlowId)) + builder.WriteString(", ") + builder.WriteString("createdAt=") + builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// ProductProcessItems is a parsable slice of ProductProcessItem. +type ProductProcessItems []*ProductProcessItem diff --git a/bj_power_mes/ent/productprocessitem/productprocessitem.go b/bj_power_mes/ent/productprocessitem/productprocessitem.go new file mode 100644 index 0000000..1350ddb --- /dev/null +++ b/bj_power_mes/ent/productprocessitem/productprocessitem.go @@ -0,0 +1,80 @@ +// Code generated by ent, DO NOT EDIT. + +package productprocessitem + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the productprocessitem type in the database. + Label = "product_process_item" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldProductProcessId holds the string denoting the productprocessid field in the database. + FieldProductProcessId = "product_process_id" + // FieldSeq holds the string denoting the seq field in the database. + FieldSeq = "seq" + // FieldFlowId holds the string denoting the flowid field in the database. + FieldFlowId = "flow_id" + // FieldCreatedAt holds the string denoting the createdat field in the database. + FieldCreatedAt = "created_at" + // Table holds the table name of the productprocessitem in the database. + Table = "product_process_item" +) + +// Columns holds all SQL columns for productprocessitem fields. +var Columns = []string{ + FieldID, + FieldProductProcessId, + FieldSeq, + FieldFlowId, + 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 ( + // DefaultCreatedAt holds the default value on creation for the "createdAt" field. + DefaultCreatedAt func() time.Time + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int) error +) + +// OrderOption defines the ordering options for the ProductProcessItem 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() +} + +// ByProductProcessId orders the results by the productProcessId field. +func ByProductProcessId(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProductProcessId, opts...).ToFunc() +} + +// BySeq orders the results by the seq field. +func BySeq(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSeq, opts...).ToFunc() +} + +// ByFlowId orders the results by the flowId field. +func ByFlowId(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldFlowId, 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/productprocessitem/where.go b/bj_power_mes/ent/productprocessitem/where.go new file mode 100644 index 0000000..715f830 --- /dev/null +++ b/bj_power_mes/ent/productprocessitem/where.go @@ -0,0 +1,250 @@ +// Code generated by ent, DO NOT EDIT. + +package productprocessitem + +import ( + "bj_power_mes/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLTE(FieldID, id)) +} + +// ProductProcessId applies equality check predicate on the "productProcessId" field. It's identical to ProductProcessIdEQ. +func ProductProcessId(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldProductProcessId, v)) +} + +// Seq applies equality check predicate on the "seq" field. It's identical to SeqEQ. +func Seq(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldSeq, v)) +} + +// FlowId applies equality check predicate on the "flowId" field. It's identical to FlowIdEQ. +func FlowId(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldFlowId, v)) +} + +// CreatedAt applies equality check predicate on the "createdAt" field. It's identical to CreatedAtEQ. +func CreatedAt(v time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldCreatedAt, v)) +} + +// ProductProcessIdEQ applies the EQ predicate on the "productProcessId" field. +func ProductProcessIdEQ(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldProductProcessId, v)) +} + +// ProductProcessIdNEQ applies the NEQ predicate on the "productProcessId" field. +func ProductProcessIdNEQ(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNEQ(FieldProductProcessId, v)) +} + +// ProductProcessIdIn applies the In predicate on the "productProcessId" field. +func ProductProcessIdIn(vs ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldIn(FieldProductProcessId, vs...)) +} + +// ProductProcessIdNotIn applies the NotIn predicate on the "productProcessId" field. +func ProductProcessIdNotIn(vs ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNotIn(FieldProductProcessId, vs...)) +} + +// ProductProcessIdGT applies the GT predicate on the "productProcessId" field. +func ProductProcessIdGT(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGT(FieldProductProcessId, v)) +} + +// ProductProcessIdGTE applies the GTE predicate on the "productProcessId" field. +func ProductProcessIdGTE(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGTE(FieldProductProcessId, v)) +} + +// ProductProcessIdLT applies the LT predicate on the "productProcessId" field. +func ProductProcessIdLT(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLT(FieldProductProcessId, v)) +} + +// ProductProcessIdLTE applies the LTE predicate on the "productProcessId" field. +func ProductProcessIdLTE(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLTE(FieldProductProcessId, v)) +} + +// SeqEQ applies the EQ predicate on the "seq" field. +func SeqEQ(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldSeq, v)) +} + +// SeqNEQ applies the NEQ predicate on the "seq" field. +func SeqNEQ(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNEQ(FieldSeq, v)) +} + +// SeqIn applies the In predicate on the "seq" field. +func SeqIn(vs ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldIn(FieldSeq, vs...)) +} + +// SeqNotIn applies the NotIn predicate on the "seq" field. +func SeqNotIn(vs ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNotIn(FieldSeq, vs...)) +} + +// SeqGT applies the GT predicate on the "seq" field. +func SeqGT(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGT(FieldSeq, v)) +} + +// SeqGTE applies the GTE predicate on the "seq" field. +func SeqGTE(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGTE(FieldSeq, v)) +} + +// SeqLT applies the LT predicate on the "seq" field. +func SeqLT(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLT(FieldSeq, v)) +} + +// SeqLTE applies the LTE predicate on the "seq" field. +func SeqLTE(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLTE(FieldSeq, v)) +} + +// FlowIdEQ applies the EQ predicate on the "flowId" field. +func FlowIdEQ(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldFlowId, v)) +} + +// FlowIdNEQ applies the NEQ predicate on the "flowId" field. +func FlowIdNEQ(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNEQ(FieldFlowId, v)) +} + +// FlowIdIn applies the In predicate on the "flowId" field. +func FlowIdIn(vs ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldIn(FieldFlowId, vs...)) +} + +// FlowIdNotIn applies the NotIn predicate on the "flowId" field. +func FlowIdNotIn(vs ...int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNotIn(FieldFlowId, vs...)) +} + +// FlowIdGT applies the GT predicate on the "flowId" field. +func FlowIdGT(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGT(FieldFlowId, v)) +} + +// FlowIdGTE applies the GTE predicate on the "flowId" field. +func FlowIdGTE(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGTE(FieldFlowId, v)) +} + +// FlowIdLT applies the LT predicate on the "flowId" field. +func FlowIdLT(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLT(FieldFlowId, v)) +} + +// FlowIdLTE applies the LTE predicate on the "flowId" field. +func FlowIdLTE(v int) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLTE(FieldFlowId, v)) +} + +// CreatedAtEQ applies the EQ predicate on the "createdAt" field. +func CreatedAtEQ(v time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldEQ(FieldCreatedAt, v)) +} + +// CreatedAtNEQ applies the NEQ predicate on the "createdAt" field. +func CreatedAtNEQ(v time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNEQ(FieldCreatedAt, v)) +} + +// CreatedAtIn applies the In predicate on the "createdAt" field. +func CreatedAtIn(vs ...time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldIn(FieldCreatedAt, vs...)) +} + +// CreatedAtNotIn applies the NotIn predicate on the "createdAt" field. +func CreatedAtNotIn(vs ...time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldNotIn(FieldCreatedAt, vs...)) +} + +// CreatedAtGT applies the GT predicate on the "createdAt" field. +func CreatedAtGT(v time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGT(FieldCreatedAt, v)) +} + +// CreatedAtGTE applies the GTE predicate on the "createdAt" field. +func CreatedAtGTE(v time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldGTE(FieldCreatedAt, v)) +} + +// CreatedAtLT applies the LT predicate on the "createdAt" field. +func CreatedAtLT(v time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLT(FieldCreatedAt, v)) +} + +// CreatedAtLTE applies the LTE predicate on the "createdAt" field. +func CreatedAtLTE(v time.Time) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.FieldLTE(FieldCreatedAt, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ProductProcessItem) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ProductProcessItem) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ProductProcessItem) predicate.ProductProcessItem { + return predicate.ProductProcessItem(sql.NotPredicates(p)) +} diff --git a/bj_power_mes/ent/productprocessitem_create.go b/bj_power_mes/ent/productprocessitem_create.go new file mode 100644 index 0000000..09cba5a --- /dev/null +++ b/bj_power_mes/ent/productprocessitem_create.go @@ -0,0 +1,258 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/productprocessitem" + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ProductProcessItemCreate is the builder for creating a ProductProcessItem entity. +type ProductProcessItemCreate struct { + config + mutation *ProductProcessItemMutation + hooks []Hook +} + +// SetProductProcessId sets the "productProcessId" field. +func (_c *ProductProcessItemCreate) SetProductProcessId(v int) *ProductProcessItemCreate { + _c.mutation.SetProductProcessId(v) + return _c +} + +// SetSeq sets the "seq" field. +func (_c *ProductProcessItemCreate) SetSeq(v int) *ProductProcessItemCreate { + _c.mutation.SetSeq(v) + return _c +} + +// SetFlowId sets the "flowId" field. +func (_c *ProductProcessItemCreate) SetFlowId(v int) *ProductProcessItemCreate { + _c.mutation.SetFlowId(v) + return _c +} + +// SetCreatedAt sets the "createdAt" field. +func (_c *ProductProcessItemCreate) SetCreatedAt(v time.Time) *ProductProcessItemCreate { + _c.mutation.SetCreatedAt(v) + return _c +} + +// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil. +func (_c *ProductProcessItemCreate) SetNillableCreatedAt(v *time.Time) *ProductProcessItemCreate { + if v != nil { + _c.SetCreatedAt(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *ProductProcessItemCreate) SetID(v int) *ProductProcessItemCreate { + _c.mutation.SetID(v) + return _c +} + +// Mutation returns the ProductProcessItemMutation object of the builder. +func (_c *ProductProcessItemCreate) Mutation() *ProductProcessItemMutation { + return _c.mutation +} + +// Save creates the ProductProcessItem in the database. +func (_c *ProductProcessItemCreate) Save(ctx context.Context) (*ProductProcessItem, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ProductProcessItemCreate) SaveX(ctx context.Context) *ProductProcessItem { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ProductProcessItemCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ProductProcessItemCreate) 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 *ProductProcessItemCreate) defaults() { + if _, ok := _c.mutation.CreatedAt(); !ok { + v := productprocessitem.DefaultCreatedAt() + _c.mutation.SetCreatedAt(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ProductProcessItemCreate) check() error { + if _, ok := _c.mutation.ProductProcessId(); !ok { + return &ValidationError{Name: "productProcessId", err: errors.New(`ent: missing required field "ProductProcessItem.productProcessId"`)} + } + if _, ok := _c.mutation.Seq(); !ok { + return &ValidationError{Name: "seq", err: errors.New(`ent: missing required field "ProductProcessItem.seq"`)} + } + if _, ok := _c.mutation.FlowId(); !ok { + return &ValidationError{Name: "flowId", err: errors.New(`ent: missing required field "ProductProcessItem.flowId"`)} + } + if _, ok := _c.mutation.CreatedAt(); !ok { + return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "ProductProcessItem.createdAt"`)} + } + if v, ok := _c.mutation.ID(); ok { + if err := productprocessitem.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "ProductProcessItem.id": %w`, err)} + } + } + return nil +} + +func (_c *ProductProcessItemCreate) sqlSave(ctx context.Context) (*ProductProcessItem, 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 *ProductProcessItemCreate) createSpec() (*ProductProcessItem, *sqlgraph.CreateSpec) { + var ( + _node = &ProductProcessItem{config: _c.config} + _spec = sqlgraph.NewCreateSpec(productprocessitem.Table, sqlgraph.NewFieldSpec(productprocessitem.FieldID, field.TypeInt)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.ProductProcessId(); ok { + _spec.SetField(productprocessitem.FieldProductProcessId, field.TypeInt, value) + _node.ProductProcessId = value + } + if value, ok := _c.mutation.Seq(); ok { + _spec.SetField(productprocessitem.FieldSeq, field.TypeInt, value) + _node.Seq = value + } + if value, ok := _c.mutation.FlowId(); ok { + _spec.SetField(productprocessitem.FieldFlowId, field.TypeInt, value) + _node.FlowId = value + } + if value, ok := _c.mutation.CreatedAt(); ok { + _spec.SetField(productprocessitem.FieldCreatedAt, field.TypeTime, value) + _node.CreatedAt = value + } + return _node, _spec +} + +// ProductProcessItemCreateBulk is the builder for creating many ProductProcessItem entities in bulk. +type ProductProcessItemCreateBulk struct { + config + err error + builders []*ProductProcessItemCreate +} + +// Save creates the ProductProcessItem entities in the database. +func (_c *ProductProcessItemCreateBulk) Save(ctx context.Context) ([]*ProductProcessItem, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*ProductProcessItem, 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.(*ProductProcessItemMutation) + 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 *ProductProcessItemCreateBulk) SaveX(ctx context.Context) []*ProductProcessItem { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ProductProcessItemCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ProductProcessItemCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/productprocessitem_delete.go b/bj_power_mes/ent/productprocessitem_delete.go new file mode 100644 index 0000000..8d3a002 --- /dev/null +++ b/bj_power_mes/ent/productprocessitem_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/productprocessitem" + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ProductProcessItemDelete is the builder for deleting a ProductProcessItem entity. +type ProductProcessItemDelete struct { + config + hooks []Hook + mutation *ProductProcessItemMutation +} + +// Where appends a list predicates to the ProductProcessItemDelete builder. +func (_d *ProductProcessItemDelete) Where(ps ...predicate.ProductProcessItem) *ProductProcessItemDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ProductProcessItemDelete) 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 *ProductProcessItemDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ProductProcessItemDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(productprocessitem.Table, sqlgraph.NewFieldSpec(productprocessitem.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 +} + +// ProductProcessItemDeleteOne is the builder for deleting a single ProductProcessItem entity. +type ProductProcessItemDeleteOne struct { + _d *ProductProcessItemDelete +} + +// Where appends a list predicates to the ProductProcessItemDelete builder. +func (_d *ProductProcessItemDeleteOne) Where(ps ...predicate.ProductProcessItem) *ProductProcessItemDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ProductProcessItemDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{productprocessitem.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ProductProcessItemDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/bj_power_mes/ent/productprocessitem_query.go b/bj_power_mes/ent/productprocessitem_query.go new file mode 100644 index 0000000..4098bcf --- /dev/null +++ b/bj_power_mes/ent/productprocessitem_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/productprocessitem" + "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" +) + +// ProductProcessItemQuery is the builder for querying ProductProcessItem entities. +type ProductProcessItemQuery struct { + config + ctx *QueryContext + order []productprocessitem.OrderOption + inters []Interceptor + predicates []predicate.ProductProcessItem + 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 ProductProcessItemQuery builder. +func (_q *ProductProcessItemQuery) Where(ps ...predicate.ProductProcessItem) *ProductProcessItemQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ProductProcessItemQuery) Limit(limit int) *ProductProcessItemQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ProductProcessItemQuery) Offset(offset int) *ProductProcessItemQuery { + _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 *ProductProcessItemQuery) Unique(unique bool) *ProductProcessItemQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ProductProcessItemQuery) Order(o ...productprocessitem.OrderOption) *ProductProcessItemQuery { + _q.order = append(_q.order, o...) + return _q +} + +// First returns the first ProductProcessItem entity from the query. +// Returns a *NotFoundError when no ProductProcessItem was found. +func (_q *ProductProcessItemQuery) First(ctx context.Context) (*ProductProcessItem, 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{productprocessitem.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ProductProcessItemQuery) FirstX(ctx context.Context) *ProductProcessItem { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ProductProcessItem ID from the query. +// Returns a *NotFoundError when no ProductProcessItem ID was found. +func (_q *ProductProcessItemQuery) 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{productprocessitem.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ProductProcessItemQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ProductProcessItem entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ProductProcessItem entity is found. +// Returns a *NotFoundError when no ProductProcessItem entities are found. +func (_q *ProductProcessItemQuery) Only(ctx context.Context) (*ProductProcessItem, 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{productprocessitem.Label} + default: + return nil, &NotSingularError{productprocessitem.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ProductProcessItemQuery) OnlyX(ctx context.Context) *ProductProcessItem { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ProductProcessItem ID in the query. +// Returns a *NotSingularError when more than one ProductProcessItem ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ProductProcessItemQuery) 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{productprocessitem.Label} + default: + err = &NotSingularError{productprocessitem.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ProductProcessItemQuery) 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 ProductProcessItems. +func (_q *ProductProcessItemQuery) All(ctx context.Context) ([]*ProductProcessItem, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ProductProcessItem, *ProductProcessItemQuery]() + return withInterceptors[[]*ProductProcessItem](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ProductProcessItemQuery) AllX(ctx context.Context) []*ProductProcessItem { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ProductProcessItem IDs. +func (_q *ProductProcessItemQuery) 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(productprocessitem.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ProductProcessItemQuery) 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 *ProductProcessItemQuery) 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[*ProductProcessItemQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ProductProcessItemQuery) 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 *ProductProcessItemQuery) 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 *ProductProcessItemQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ProductProcessItemQuery 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 *ProductProcessItemQuery) Clone() *ProductProcessItemQuery { + if _q == nil { + return nil + } + return &ProductProcessItemQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]productprocessitem.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.ProductProcessItem{}, _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 { +// ProductProcessId int `json:"productProcessId,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ProductProcessItem.Query(). +// GroupBy(productprocessitem.FieldProductProcessId). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ProductProcessItemQuery) GroupBy(field string, fields ...string) *ProductProcessItemGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ProductProcessItemGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = productprocessitem.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 { +// ProductProcessId int `json:"productProcessId,omitempty"` +// } +// +// client.ProductProcessItem.Query(). +// Select(productprocessitem.FieldProductProcessId). +// Scan(ctx, &v) +func (_q *ProductProcessItemQuery) Select(fields ...string) *ProductProcessItemSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ProductProcessItemSelect{ProductProcessItemQuery: _q} + sbuild.label = productprocessitem.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ProductProcessItemSelect configured with the given aggregations. +func (_q *ProductProcessItemQuery) Aggregate(fns ...AggregateFunc) *ProductProcessItemSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ProductProcessItemQuery) 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 !productprocessitem.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 *ProductProcessItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ProductProcessItem, error) { + var ( + nodes = []*ProductProcessItem{} + _spec = _q.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ProductProcessItem).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ProductProcessItem{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 *ProductProcessItemQuery) 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 *ProductProcessItemQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(productprocessitem.Table, productprocessitem.Columns, sqlgraph.NewFieldSpec(productprocessitem.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, productprocessitem.FieldID) + for i := range fields { + if fields[i] != productprocessitem.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 *ProductProcessItemQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(productprocessitem.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = productprocessitem.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 *ProductProcessItemQuery) ForUpdate(opts ...sql.LockOption) *ProductProcessItemQuery { + 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 *ProductProcessItemQuery) ForShare(opts ...sql.LockOption) *ProductProcessItemQuery { + 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 *ProductProcessItemQuery) Modify(modifiers ...func(s *sql.Selector)) *ProductProcessItemSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// ProductProcessItemGroupBy is the group-by builder for ProductProcessItem entities. +type ProductProcessItemGroupBy struct { + selector + build *ProductProcessItemQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ProductProcessItemGroupBy) Aggregate(fns ...AggregateFunc) *ProductProcessItemGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ProductProcessItemGroupBy) 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[*ProductProcessItemQuery, *ProductProcessItemGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ProductProcessItemGroupBy) sqlScan(ctx context.Context, root *ProductProcessItemQuery, 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) +} + +// ProductProcessItemSelect is the builder for selecting fields of ProductProcessItem entities. +type ProductProcessItemSelect struct { + *ProductProcessItemQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ProductProcessItemSelect) Aggregate(fns ...AggregateFunc) *ProductProcessItemSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ProductProcessItemSelect) 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[*ProductProcessItemQuery, *ProductProcessItemSelect](ctx, _s.ProductProcessItemQuery, _s, _s.inters, v) +} + +func (_s *ProductProcessItemSelect) sqlScan(ctx context.Context, root *ProductProcessItemQuery, 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 *ProductProcessItemSelect) Modify(modifiers ...func(s *sql.Selector)) *ProductProcessItemSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/bj_power_mes/ent/productprocessitem_update.go b/bj_power_mes/ent/productprocessitem_update.go new file mode 100644 index 0000000..85083e3 --- /dev/null +++ b/bj_power_mes/ent/productprocessitem_update.go @@ -0,0 +1,353 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "bj_power_mes/ent/predicate" + "bj_power_mes/ent/productprocessitem" + "context" + "errors" + "fmt" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ProductProcessItemUpdate is the builder for updating ProductProcessItem entities. +type ProductProcessItemUpdate struct { + config + hooks []Hook + mutation *ProductProcessItemMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ProductProcessItemUpdate builder. +func (_u *ProductProcessItemUpdate) Where(ps ...predicate.ProductProcessItem) *ProductProcessItemUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetProductProcessId sets the "productProcessId" field. +func (_u *ProductProcessItemUpdate) SetProductProcessId(v int) *ProductProcessItemUpdate { + _u.mutation.ResetProductProcessId() + _u.mutation.SetProductProcessId(v) + return _u +} + +// SetNillableProductProcessId sets the "productProcessId" field if the given value is not nil. +func (_u *ProductProcessItemUpdate) SetNillableProductProcessId(v *int) *ProductProcessItemUpdate { + if v != nil { + _u.SetProductProcessId(*v) + } + return _u +} + +// AddProductProcessId adds value to the "productProcessId" field. +func (_u *ProductProcessItemUpdate) AddProductProcessId(v int) *ProductProcessItemUpdate { + _u.mutation.AddProductProcessId(v) + return _u +} + +// SetSeq sets the "seq" field. +func (_u *ProductProcessItemUpdate) SetSeq(v int) *ProductProcessItemUpdate { + _u.mutation.ResetSeq() + _u.mutation.SetSeq(v) + return _u +} + +// SetNillableSeq sets the "seq" field if the given value is not nil. +func (_u *ProductProcessItemUpdate) SetNillableSeq(v *int) *ProductProcessItemUpdate { + if v != nil { + _u.SetSeq(*v) + } + return _u +} + +// AddSeq adds value to the "seq" field. +func (_u *ProductProcessItemUpdate) AddSeq(v int) *ProductProcessItemUpdate { + _u.mutation.AddSeq(v) + return _u +} + +// SetFlowId sets the "flowId" field. +func (_u *ProductProcessItemUpdate) SetFlowId(v int) *ProductProcessItemUpdate { + _u.mutation.ResetFlowId() + _u.mutation.SetFlowId(v) + return _u +} + +// SetNillableFlowId sets the "flowId" field if the given value is not nil. +func (_u *ProductProcessItemUpdate) SetNillableFlowId(v *int) *ProductProcessItemUpdate { + if v != nil { + _u.SetFlowId(*v) + } + return _u +} + +// AddFlowId adds value to the "flowId" field. +func (_u *ProductProcessItemUpdate) AddFlowId(v int) *ProductProcessItemUpdate { + _u.mutation.AddFlowId(v) + return _u +} + +// Mutation returns the ProductProcessItemMutation object of the builder. +func (_u *ProductProcessItemUpdate) Mutation() *ProductProcessItemMutation { + return _u.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ProductProcessItemUpdate) 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 *ProductProcessItemUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ProductProcessItemUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ProductProcessItemUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ProductProcessItemUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProductProcessItemUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ProductProcessItemUpdate) sqlSave(ctx context.Context) (_node int, err error) { + _spec := sqlgraph.NewUpdateSpec(productprocessitem.Table, productprocessitem.Columns, sqlgraph.NewFieldSpec(productprocessitem.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.ProductProcessId(); ok { + _spec.SetField(productprocessitem.FieldProductProcessId, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProductProcessId(); ok { + _spec.AddField(productprocessitem.FieldProductProcessId, field.TypeInt, value) + } + if value, ok := _u.mutation.Seq(); ok { + _spec.SetField(productprocessitem.FieldSeq, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSeq(); ok { + _spec.AddField(productprocessitem.FieldSeq, field.TypeInt, value) + } + if value, ok := _u.mutation.FlowId(); ok { + _spec.SetField(productprocessitem.FieldFlowId, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedFlowId(); ok { + _spec.AddField(productprocessitem.FieldFlowId, field.TypeInt, value) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{productprocessitem.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ProductProcessItemUpdateOne is the builder for updating a single ProductProcessItem entity. +type ProductProcessItemUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ProductProcessItemMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetProductProcessId sets the "productProcessId" field. +func (_u *ProductProcessItemUpdateOne) SetProductProcessId(v int) *ProductProcessItemUpdateOne { + _u.mutation.ResetProductProcessId() + _u.mutation.SetProductProcessId(v) + return _u +} + +// SetNillableProductProcessId sets the "productProcessId" field if the given value is not nil. +func (_u *ProductProcessItemUpdateOne) SetNillableProductProcessId(v *int) *ProductProcessItemUpdateOne { + if v != nil { + _u.SetProductProcessId(*v) + } + return _u +} + +// AddProductProcessId adds value to the "productProcessId" field. +func (_u *ProductProcessItemUpdateOne) AddProductProcessId(v int) *ProductProcessItemUpdateOne { + _u.mutation.AddProductProcessId(v) + return _u +} + +// SetSeq sets the "seq" field. +func (_u *ProductProcessItemUpdateOne) SetSeq(v int) *ProductProcessItemUpdateOne { + _u.mutation.ResetSeq() + _u.mutation.SetSeq(v) + return _u +} + +// SetNillableSeq sets the "seq" field if the given value is not nil. +func (_u *ProductProcessItemUpdateOne) SetNillableSeq(v *int) *ProductProcessItemUpdateOne { + if v != nil { + _u.SetSeq(*v) + } + return _u +} + +// AddSeq adds value to the "seq" field. +func (_u *ProductProcessItemUpdateOne) AddSeq(v int) *ProductProcessItemUpdateOne { + _u.mutation.AddSeq(v) + return _u +} + +// SetFlowId sets the "flowId" field. +func (_u *ProductProcessItemUpdateOne) SetFlowId(v int) *ProductProcessItemUpdateOne { + _u.mutation.ResetFlowId() + _u.mutation.SetFlowId(v) + return _u +} + +// SetNillableFlowId sets the "flowId" field if the given value is not nil. +func (_u *ProductProcessItemUpdateOne) SetNillableFlowId(v *int) *ProductProcessItemUpdateOne { + if v != nil { + _u.SetFlowId(*v) + } + return _u +} + +// AddFlowId adds value to the "flowId" field. +func (_u *ProductProcessItemUpdateOne) AddFlowId(v int) *ProductProcessItemUpdateOne { + _u.mutation.AddFlowId(v) + return _u +} + +// Mutation returns the ProductProcessItemMutation object of the builder. +func (_u *ProductProcessItemUpdateOne) Mutation() *ProductProcessItemMutation { + return _u.mutation +} + +// Where appends a list predicates to the ProductProcessItemUpdate builder. +func (_u *ProductProcessItemUpdateOne) Where(ps ...predicate.ProductProcessItem) *ProductProcessItemUpdateOne { + _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 *ProductProcessItemUpdateOne) Select(field string, fields ...string) *ProductProcessItemUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated ProductProcessItem entity. +func (_u *ProductProcessItemUpdateOne) Save(ctx context.Context) (*ProductProcessItem, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ProductProcessItemUpdateOne) SaveX(ctx context.Context) *ProductProcessItem { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ProductProcessItemUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ProductProcessItemUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ProductProcessItemUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProductProcessItemUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ProductProcessItemUpdateOne) sqlSave(ctx context.Context) (_node *ProductProcessItem, err error) { + _spec := sqlgraph.NewUpdateSpec(productprocessitem.Table, productprocessitem.Columns, sqlgraph.NewFieldSpec(productprocessitem.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ProductProcessItem.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, productprocessitem.FieldID) + for _, f := range fields { + if !productprocessitem.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != productprocessitem.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.ProductProcessId(); ok { + _spec.SetField(productprocessitem.FieldProductProcessId, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProductProcessId(); ok { + _spec.AddField(productprocessitem.FieldProductProcessId, field.TypeInt, value) + } + if value, ok := _u.mutation.Seq(); ok { + _spec.SetField(productprocessitem.FieldSeq, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSeq(); ok { + _spec.AddField(productprocessitem.FieldSeq, field.TypeInt, value) + } + if value, ok := _u.mutation.FlowId(); ok { + _spec.SetField(productprocessitem.FieldFlowId, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedFlowId(); ok { + _spec.AddField(productprocessitem.FieldFlowId, field.TypeInt, value) + } + _spec.AddModifiers(_u.modifiers...) + _node = &ProductProcessItem{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{productprocessitem.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/runtime.go b/bj_power_mes/ent/runtime.go index 017adc0..1efe928 100644 --- a/bj_power_mes/ent/runtime.go +++ b/bj_power_mes/ent/runtime.go @@ -20,6 +20,8 @@ import ( "bj_power_mes/ent/plcsendlog" "bj_power_mes/ent/processflow" "bj_power_mes/ent/processstep" + "bj_power_mes/ent/productprocess" + "bj_power_mes/ent/productprocessitem" "bj_power_mes/ent/role" "bj_power_mes/ent/semiflow" "bj_power_mes/ent/station" @@ -1081,20 +1083,80 @@ func init() { processstepDescNeedInspectorSign := processstepFields[8].Descriptor() // processstep.DefaultNeedInspectorSign holds the default value on creation for the needInspectorSign field. processstep.DefaultNeedInspectorSign = processstepDescNeedInspectorSign.Default.(bool) + // processstepDescNeedAudit is the schema descriptor for needAudit field. + processstepDescNeedAudit := processstepFields[9].Descriptor() + // processstep.DefaultNeedAudit holds the default value on creation for the needAudit field. + processstep.DefaultNeedAudit = processstepDescNeedAudit.Default.(bool) + // processstepDescAuditRole is the schema descriptor for auditRole field. + processstepDescAuditRole := processstepFields[10].Descriptor() + // processstep.DefaultAuditRole holds the default value on creation for the auditRole field. + processstep.DefaultAuditRole = processstepDescAuditRole.Default.(string) + // processstep.AuditRoleValidator is a validator for the "auditRole" field. It is called by the builders before save. + processstep.AuditRoleValidator = processstepDescAuditRole.Validators[0].(func(string) error) // processstepDescRemark is the schema descriptor for remark field. - processstepDescRemark := processstepFields[10].Descriptor() + processstepDescRemark := processstepFields[12].Descriptor() // processstep.DefaultRemark holds the default value on creation for the remark field. processstep.DefaultRemark = processstepDescRemark.Default.(string) // processstep.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. processstep.RemarkValidator = processstepDescRemark.Validators[0].(func(string) error) // processstepDescCreatedAt is the schema descriptor for createdAt field. - processstepDescCreatedAt := processstepFields[11].Descriptor() + processstepDescCreatedAt := processstepFields[13].Descriptor() // processstep.DefaultCreatedAt holds the default value on creation for the createdAt field. processstep.DefaultCreatedAt = processstepDescCreatedAt.Default.(func() time.Time) // processstepDescID is the schema descriptor for id field. processstepDescID := processstepFields[0].Descriptor() // processstep.IDValidator is a validator for the "id" field. It is called by the builders before save. processstep.IDValidator = processstepDescID.Validators[0].(func(int) error) + productprocessFields := schema.ProductProcess{}.Fields() + _ = productprocessFields + // productprocessDescProductCode is the schema descriptor for productCode field. + productprocessDescProductCode := productprocessFields[1].Descriptor() + // productprocess.ProductCodeValidator is a validator for the "productCode" field. It is called by the builders before save. + productprocess.ProductCodeValidator = productprocessDescProductCode.Validators[0].(func(string) error) + // productprocessDescProductName is the schema descriptor for productName field. + productprocessDescProductName := productprocessFields[2].Descriptor() + // productprocess.DefaultProductName holds the default value on creation for the productName field. + productprocess.DefaultProductName = productprocessDescProductName.Default.(string) + // productprocess.ProductNameValidator is a validator for the "productName" field. It is called by the builders before save. + productprocess.ProductNameValidator = productprocessDescProductName.Validators[0].(func(string) error) + // productprocessDescName is the schema descriptor for name field. + productprocessDescName := productprocessFields[3].Descriptor() + // productprocess.NameValidator is a validator for the "name" field. It is called by the builders before save. + productprocess.NameValidator = productprocessDescName.Validators[0].(func(string) error) + // productprocessDescIsDefault is the schema descriptor for isDefault field. + productprocessDescIsDefault := productprocessFields[4].Descriptor() + // productprocess.DefaultIsDefault holds the default value on creation for the isDefault field. + productprocess.DefaultIsDefault = productprocessDescIsDefault.Default.(bool) + // productprocessDescStatus is the schema descriptor for status field. + productprocessDescStatus := productprocessFields[5].Descriptor() + // productprocess.DefaultStatus holds the default value on creation for the status field. + productprocess.DefaultStatus = productprocessDescStatus.Default.(string) + // productprocess.StatusValidator is a validator for the "status" field. It is called by the builders before save. + productprocess.StatusValidator = productprocessDescStatus.Validators[0].(func(string) error) + // productprocessDescRemark is the schema descriptor for remark field. + productprocessDescRemark := productprocessFields[6].Descriptor() + // productprocess.DefaultRemark holds the default value on creation for the remark field. + productprocess.DefaultRemark = productprocessDescRemark.Default.(string) + // productprocess.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. + productprocess.RemarkValidator = productprocessDescRemark.Validators[0].(func(string) error) + // productprocessDescCreatedAt is the schema descriptor for createdAt field. + productprocessDescCreatedAt := productprocessFields[7].Descriptor() + // productprocess.DefaultCreatedAt holds the default value on creation for the createdAt field. + productprocess.DefaultCreatedAt = productprocessDescCreatedAt.Default.(func() time.Time) + // productprocessDescID is the schema descriptor for id field. + productprocessDescID := productprocessFields[0].Descriptor() + // productprocess.IDValidator is a validator for the "id" field. It is called by the builders before save. + productprocess.IDValidator = productprocessDescID.Validators[0].(func(int) error) + productprocessitemFields := schema.ProductProcessItem{}.Fields() + _ = productprocessitemFields + // productprocessitemDescCreatedAt is the schema descriptor for createdAt field. + productprocessitemDescCreatedAt := productprocessitemFields[4].Descriptor() + // productprocessitem.DefaultCreatedAt holds the default value on creation for the createdAt field. + productprocessitem.DefaultCreatedAt = productprocessitemDescCreatedAt.Default.(func() time.Time) + // productprocessitemDescID is the schema descriptor for id field. + productprocessitemDescID := productprocessitemFields[0].Descriptor() + // productprocessitem.IDValidator is a validator for the "id" field. It is called by the builders before save. + productprocessitem.IDValidator = productprocessitemDescID.Validators[0].(func(int) error) roleFields := schema.Role{}.Fields() _ = roleFields // roleDescName is the schema descriptor for name field. @@ -1601,18 +1663,22 @@ func init() { workorder.DefaultCreatedBy = workorderDescCreatedBy.Default.(string) // workorder.CreatedByValidator is a validator for the "createdBy" field. It is called by the builders before save. workorder.CreatedByValidator = workorderDescCreatedBy.Validators[0].(func(string) error) + // workorderDescProductProcessId is the schema descriptor for productProcessId field. + workorderDescProductProcessId := workorderFields[15].Descriptor() + // workorder.DefaultProductProcessId holds the default value on creation for the productProcessId field. + workorder.DefaultProductProcessId = workorderDescProductProcessId.Default.(int) // workorderDescStatus is the schema descriptor for status field. - workorderDescStatus := workorderFields[15].Descriptor() + workorderDescStatus := workorderFields[16].Descriptor() // workorder.DefaultStatus holds the default value on creation for the status field. workorder.DefaultStatus = workorderDescStatus.Default.(string) // workorder.StatusValidator is a validator for the "status" field. It is called by the builders before save. workorder.StatusValidator = workorderDescStatus.Validators[0].(func(string) error) // workorderDescCreatedAt is the schema descriptor for createdAt field. - workorderDescCreatedAt := workorderFields[20].Descriptor() + workorderDescCreatedAt := workorderFields[21].Descriptor() // workorder.DefaultCreatedAt holds the default value on creation for the createdAt field. workorder.DefaultCreatedAt = workorderDescCreatedAt.Default.(func() time.Time) // workorderDescUpdatedAt is the schema descriptor for updatedAt field. - workorderDescUpdatedAt := workorderFields[21].Descriptor() + workorderDescUpdatedAt := workorderFields[22].Descriptor() // workorder.DefaultUpdatedAt holds the default value on creation for the updatedAt field. workorder.DefaultUpdatedAt = workorderDescUpdatedAt.Default.(func() time.Time) // workorder.UpdateDefaultUpdatedAt holds the default value on update for the updatedAt field. diff --git a/bj_power_mes/ent/tx.go b/bj_power_mes/ent/tx.go index 9536454..9a55182 100644 --- a/bj_power_mes/ent/tx.go +++ b/bj_power_mes/ent/tx.go @@ -46,6 +46,10 @@ type Tx struct { ProcessFlow *ProcessFlowClient // ProcessStep is the client for interacting with the ProcessStep builders. ProcessStep *ProcessStepClient + // ProductProcess is the client for interacting with the ProductProcess builders. + ProductProcess *ProductProcessClient + // ProductProcessItem is the client for interacting with the ProductProcessItem builders. + ProductProcessItem *ProductProcessItemClient // Role is the client for interacting with the Role builders. Role *RoleClient // SemiFlow is the client for interacting with the SemiFlow builders. @@ -224,6 +228,8 @@ func (tx *Tx) init() { tx.PlcSendLog = NewPlcSendLogClient(tx.config) tx.ProcessFlow = NewProcessFlowClient(tx.config) tx.ProcessStep = NewProcessStepClient(tx.config) + tx.ProductProcess = NewProductProcessClient(tx.config) + tx.ProductProcessItem = NewProductProcessItemClient(tx.config) tx.Role = NewRoleClient(tx.config) tx.SemiFlow = NewSemiFlowClient(tx.config) tx.Station = NewStationClient(tx.config) diff --git a/bj_power_mes/ent/workorder.go b/bj_power_mes/ent/workorder.go index fce9abc..399a8ed 100644 --- a/bj_power_mes/ent/workorder.go +++ b/bj_power_mes/ent/workorder.go @@ -46,6 +46,8 @@ type WorkOrder struct { DueDate *time.Time `json:"dueDate,omitempty"` // 工艺组合 [{flowId,stationNo}] 按工位号升序 FlowCombination []map[string]int `json:"flowCombination,omitempty"` + // 来源产品工艺ID(0=无来源) + ProductProcessId int `json:"productProcessId,omitempty"` // Status holds the value of the "status" field. Status string `json:"status,omitempty"` // 计划开始 @@ -70,7 +72,7 @@ func (*WorkOrder) scanValues(columns []string) ([]any, error) { switch columns[i] { case workorder.FieldFlowCombination, workorder.FieldContext: values[i] = new([]byte) - case workorder.FieldID, workorder.FieldProductTypeId, workorder.FieldQuantity, workorder.FieldFinishedNum, workorder.FieldFailNum: + case workorder.FieldID, workorder.FieldProductTypeId, workorder.FieldQuantity, workorder.FieldFinishedNum, workorder.FieldFailNum, workorder.FieldProductProcessId: values[i] = new(sql.NullInt64) case workorder.FieldWorkOrderNo, workorder.FieldProductCode, workorder.FieldProductName, workorder.FieldContractNo, workorder.FieldOwnershipType, workorder.FieldProjectNo, workorder.FieldProductSerial, workorder.FieldCreatedBy, workorder.FieldStatus: values[i] = new(sql.NullString) @@ -184,6 +186,12 @@ func (_m *WorkOrder) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field flowCombination: %w", err) } } + case workorder.FieldProductProcessId: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field productProcessId", values[i]) + } else if value.Valid { + _m.ProductProcessId = int(value.Int64) + } case workorder.FieldStatus: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) @@ -312,6 +320,9 @@ func (_m *WorkOrder) String() string { builder.WriteString("flowCombination=") builder.WriteString(fmt.Sprintf("%v", _m.FlowCombination)) builder.WriteString(", ") + builder.WriteString("productProcessId=") + builder.WriteString(fmt.Sprintf("%v", _m.ProductProcessId)) + builder.WriteString(", ") builder.WriteString("status=") builder.WriteString(_m.Status) builder.WriteString(", ") diff --git a/bj_power_mes/ent/workorder/where.go b/bj_power_mes/ent/workorder/where.go index 3465f94..32de3fe 100644 --- a/bj_power_mes/ent/workorder/where.go +++ b/bj_power_mes/ent/workorder/where.go @@ -119,6 +119,11 @@ func DueDate(v time.Time) predicate.WorkOrder { return predicate.WorkOrder(sql.FieldEQ(FieldDueDate, v)) } +// ProductProcessId applies equality check predicate on the "productProcessId" field. It's identical to ProductProcessIdEQ. +func ProductProcessId(v int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldEQ(FieldProductProcessId, v)) +} + // Status applies equality check predicate on the "status" field. It's identical to StatusEQ. func Status(v string) predicate.WorkOrder { return predicate.WorkOrder(sql.FieldEQ(FieldStatus, v)) @@ -889,6 +894,46 @@ func FlowCombinationNotNil() predicate.WorkOrder { return predicate.WorkOrder(sql.FieldNotNull(FieldFlowCombination)) } +// ProductProcessIdEQ applies the EQ predicate on the "productProcessId" field. +func ProductProcessIdEQ(v int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldEQ(FieldProductProcessId, v)) +} + +// ProductProcessIdNEQ applies the NEQ predicate on the "productProcessId" field. +func ProductProcessIdNEQ(v int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldNEQ(FieldProductProcessId, v)) +} + +// ProductProcessIdIn applies the In predicate on the "productProcessId" field. +func ProductProcessIdIn(vs ...int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldIn(FieldProductProcessId, vs...)) +} + +// ProductProcessIdNotIn applies the NotIn predicate on the "productProcessId" field. +func ProductProcessIdNotIn(vs ...int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldNotIn(FieldProductProcessId, vs...)) +} + +// ProductProcessIdGT applies the GT predicate on the "productProcessId" field. +func ProductProcessIdGT(v int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldGT(FieldProductProcessId, v)) +} + +// ProductProcessIdGTE applies the GTE predicate on the "productProcessId" field. +func ProductProcessIdGTE(v int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldGTE(FieldProductProcessId, v)) +} + +// ProductProcessIdLT applies the LT predicate on the "productProcessId" field. +func ProductProcessIdLT(v int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldLT(FieldProductProcessId, v)) +} + +// ProductProcessIdLTE applies the LTE predicate on the "productProcessId" field. +func ProductProcessIdLTE(v int) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldLTE(FieldProductProcessId, v)) +} + // StatusEQ applies the EQ predicate on the "status" field. func StatusEQ(v string) predicate.WorkOrder { return predicate.WorkOrder(sql.FieldEQ(FieldStatus, v)) diff --git a/bj_power_mes/ent/workorder/workorder.go b/bj_power_mes/ent/workorder/workorder.go index 55a2bb7..c77453f 100644 --- a/bj_power_mes/ent/workorder/workorder.go +++ b/bj_power_mes/ent/workorder/workorder.go @@ -41,6 +41,8 @@ const ( FieldDueDate = "due_date" // FieldFlowCombination holds the string denoting the flowcombination field in the database. FieldFlowCombination = "flow_combination" + // FieldProductProcessId holds the string denoting the productprocessid field in the database. + FieldProductProcessId = "product_process_id" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" // FieldPlanStart holds the string denoting the planstart field in the database. @@ -76,6 +78,7 @@ var Columns = []string{ FieldCreatedBy, FieldDueDate, FieldFlowCombination, + FieldProductProcessId, FieldStatus, FieldPlanStart, FieldPlanEnd, @@ -132,6 +135,8 @@ var ( DefaultCreatedBy string // CreatedByValidator is a validator for the "createdBy" field. It is called by the builders before save. CreatedByValidator func(string) error + // DefaultProductProcessId holds the default value on creation for the "productProcessId" field. + DefaultProductProcessId int // 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. @@ -219,6 +224,11 @@ func ByDueDate(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDueDate, opts...).ToFunc() } +// ByProductProcessId orders the results by the productProcessId field. +func ByProductProcessId(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProductProcessId, opts...).ToFunc() +} + // ByStatus orders the results by the status field. func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() diff --git a/bj_power_mes/ent/workorder_create.go b/bj_power_mes/ent/workorder_create.go index c02db99..40f0a6b 100644 --- a/bj_power_mes/ent/workorder_create.go +++ b/bj_power_mes/ent/workorder_create.go @@ -192,6 +192,20 @@ func (_c *WorkOrderCreate) SetFlowCombination(v []map[string]int) *WorkOrderCrea return _c } +// SetProductProcessId sets the "productProcessId" field. +func (_c *WorkOrderCreate) SetProductProcessId(v int) *WorkOrderCreate { + _c.mutation.SetProductProcessId(v) + return _c +} + +// SetNillableProductProcessId sets the "productProcessId" field if the given value is not nil. +func (_c *WorkOrderCreate) SetNillableProductProcessId(v *int) *WorkOrderCreate { + if v != nil { + _c.SetProductProcessId(*v) + } + return _c +} + // SetStatus sets the "status" field. func (_c *WorkOrderCreate) SetStatus(v string) *WorkOrderCreate { _c.mutation.SetStatus(v) @@ -363,6 +377,10 @@ func (_c *WorkOrderCreate) defaults() { v := workorder.DefaultCreatedBy _c.mutation.SetCreatedBy(v) } + if _, ok := _c.mutation.ProductProcessId(); !ok { + v := workorder.DefaultProductProcessId + _c.mutation.SetProductProcessId(v) + } if _, ok := _c.mutation.Status(); !ok { v := workorder.DefaultStatus _c.mutation.SetStatus(v) @@ -455,6 +473,9 @@ func (_c *WorkOrderCreate) check() error { return &ValidationError{Name: "createdBy", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.createdBy": %w`, err)} } } + if _, ok := _c.mutation.ProductProcessId(); !ok { + return &ValidationError{Name: "productProcessId", err: errors.New(`ent: missing required field "WorkOrder.productProcessId"`)} + } if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "WorkOrder.status"`)} } @@ -559,6 +580,10 @@ func (_c *WorkOrderCreate) createSpec() (*WorkOrder, *sqlgraph.CreateSpec) { _spec.SetField(workorder.FieldFlowCombination, field.TypeJSON, value) _node.FlowCombination = value } + if value, ok := _c.mutation.ProductProcessId(); ok { + _spec.SetField(workorder.FieldProductProcessId, field.TypeInt, value) + _node.ProductProcessId = value + } if value, ok := _c.mutation.Status(); ok { _spec.SetField(workorder.FieldStatus, field.TypeString, value) _node.Status = value diff --git a/bj_power_mes/ent/workorder_update.go b/bj_power_mes/ent/workorder_update.go index a0c9b25..d367449 100644 --- a/bj_power_mes/ent/workorder_update.go +++ b/bj_power_mes/ent/workorder_update.go @@ -264,6 +264,27 @@ func (_u *WorkOrderUpdate) ClearFlowCombination() *WorkOrderUpdate { return _u } +// SetProductProcessId sets the "productProcessId" field. +func (_u *WorkOrderUpdate) SetProductProcessId(v int) *WorkOrderUpdate { + _u.mutation.ResetProductProcessId() + _u.mutation.SetProductProcessId(v) + return _u +} + +// SetNillableProductProcessId sets the "productProcessId" field if the given value is not nil. +func (_u *WorkOrderUpdate) SetNillableProductProcessId(v *int) *WorkOrderUpdate { + if v != nil { + _u.SetProductProcessId(*v) + } + return _u +} + +// AddProductProcessId adds value to the "productProcessId" field. +func (_u *WorkOrderUpdate) AddProductProcessId(v int) *WorkOrderUpdate { + _u.mutation.AddProductProcessId(v) + return _u +} + // SetStatus sets the "status" field. func (_u *WorkOrderUpdate) SetStatus(v string) *WorkOrderUpdate { _u.mutation.SetStatus(v) @@ -536,6 +557,12 @@ func (_u *WorkOrderUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.FlowCombinationCleared() { _spec.ClearField(workorder.FieldFlowCombination, field.TypeJSON) } + if value, ok := _u.mutation.ProductProcessId(); ok { + _spec.SetField(workorder.FieldProductProcessId, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProductProcessId(); ok { + _spec.AddField(workorder.FieldProductProcessId, field.TypeInt, value) + } if value, ok := _u.mutation.Status(); ok { _spec.SetField(workorder.FieldStatus, field.TypeString, value) } @@ -825,6 +852,27 @@ func (_u *WorkOrderUpdateOne) ClearFlowCombination() *WorkOrderUpdateOne { return _u } +// SetProductProcessId sets the "productProcessId" field. +func (_u *WorkOrderUpdateOne) SetProductProcessId(v int) *WorkOrderUpdateOne { + _u.mutation.ResetProductProcessId() + _u.mutation.SetProductProcessId(v) + return _u +} + +// SetNillableProductProcessId sets the "productProcessId" field if the given value is not nil. +func (_u *WorkOrderUpdateOne) SetNillableProductProcessId(v *int) *WorkOrderUpdateOne { + if v != nil { + _u.SetProductProcessId(*v) + } + return _u +} + +// AddProductProcessId adds value to the "productProcessId" field. +func (_u *WorkOrderUpdateOne) AddProductProcessId(v int) *WorkOrderUpdateOne { + _u.mutation.AddProductProcessId(v) + return _u +} + // SetStatus sets the "status" field. func (_u *WorkOrderUpdateOne) SetStatus(v string) *WorkOrderUpdateOne { _u.mutation.SetStatus(v) @@ -1127,6 +1175,12 @@ func (_u *WorkOrderUpdateOne) sqlSave(ctx context.Context) (_node *WorkOrder, er if _u.mutation.FlowCombinationCleared() { _spec.ClearField(workorder.FieldFlowCombination, field.TypeJSON) } + if value, ok := _u.mutation.ProductProcessId(); ok { + _spec.SetField(workorder.FieldProductProcessId, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedProductProcessId(); ok { + _spec.AddField(workorder.FieldProductProcessId, field.TypeInt, value) + } if value, ok := _u.mutation.Status(); ok { _spec.SetField(workorder.FieldStatus, field.TypeString, value) } diff --git a/bj_power_mes/frontend/src/help.js b/bj_power_mes/frontend/src/help.js index 433ba86..ecaaddc 100644 --- a/bj_power_mes/frontend/src/help.js +++ b/bj_power_mes/frontend/src/help.js @@ -438,16 +438,42 @@ export const helpInspect = { export const helpProcessCard = { - title: '生产流程卡(产品型号级全景流程卡)', + title: '生产流程卡(工单维度主卡)', overview: - '这个菜单做什么用:按**产品型号**全方位展示该型号的完整制造定义,用于工艺交底、审核与客户查阅;与「工件追溯」页里按单个 SN 打印的流程卡互补——后者记的是“这一件实际怎么做的”,本页讲的是“这个型号应该怎么做”。\n\n内容构成(页面按页签展示,打印时全部输出):①工位流程总览——工艺组合、每工位绑定的工艺、工艺状态、步骤数、检验点数、拧紧步骤数、工艺图纸、该型号的历史作业时间;②工艺与步骤——逐工位列出每条步骤的采集方式(手工录入/自动采集/无需采集)、是否需检测确认、是否拧紧采集、考核标准(含上下限);③物料清单——该型号的物料清单明细,按物料清单名称分组,含图号/名称/规格/单位/管理方式/单台用量/损耗率/需求总量;④检验卡项——把所有「需要检测确认」的步骤汇总成检验项清单,含判定标准。\n\n工艺组合从哪来:优先取该产品编号最近一张工单的「工艺组合」;若该型号还没有工单,则按全产线工位顺序(升序)展示,页面顶部会标注来源。\n\n打印/导出:点「打印 / 导出 PDF」,系统会在新窗口打开排版好的 A4 卡片版式,用浏览器打印即可(选择“另存为 PDF”即导出电子档)。', + '本页以**工单**为唯一主键,展示该工单的「生产实绩 / 追溯卡」:工序实绩、用料清单、成品明细与签字确认;并保留成品 SN 维度的追溯子视图。\n\n三个查询入口(数据源同一套):\n· 工单号 → 工单主卡(首选);\n· 成品SN → 成品追溯卡(SN 维度,逐件追溯工序/用料/拧紧/签字);\n· 产品型号 → 该型号下的工单列表(仅筛选入口,点行内「查看主卡」回到工单维度)。\n\n概念统一:物料「类型」(结构件/电气件/其他)取自 WMS 物料档案 manage_mode;物料「序列号」(序列号件逐件录 SN / 批次件按批)两维严格分离。用料清单按 序列号件 / 批次件 两组分别展示。\n\n用料清单数据来自装配实绩(工位终端装机绑定 workpiece_bind):序列号件列出每件实际 SN,批次件列出批次号。\n\n签字区:操作工 / 检验员 / 审核人 按实际签字人展示(含签字次数与最近时间),单据级「批准人」留手签空位,系统不代填、不加字段。\n\n打印/导出:点「打印 / 导出 PDF」,系统在新窗口打开排版好的 A4 卡片版式,浏览器打印选「另存为 PDF」即导出电子档。', fields: [ - { name: '产品型号', source: '下拉选择,来自「物料档案」页。', purpose: '要查看哪个型号的全景流程', fill: '选定后自动带出产品编号' }, - { name: '产品编号', source: '自动带出(也可手工填写,直接按编号生成)。', purpose: '匹配工单、物料清单的关键字', fill: '一般无需手填' }, - { name: '工艺组合', source: '只读,自动带出。', purpose: '该型号要走哪些工位、按什么顺序', fill: '-' }, - { name: '工位流程总览-工艺图纸', source: '来自「工艺」页上传的图纸文件名。', purpose: '该工位是否有可查阅的工艺图', fill: '-' }, - { name: '工位流程总览-作业时间', source: '按本型号历史报工实绩聚合的首末作业时间。', purpose: '了解各环节实际耗时', fill: '无实绩时显示“暂无实绩”' }, - { name: '检验卡项', source: '自动汇总所有「检测确认」步骤。', purpose: '作为检验清单使用', fill: '-' } + { name: '产品型号', source: '下拉选择,来自「物料档案」页(WMS 物料主数据)。', purpose: '按型号筛选其下工单列表', fill: '选定后清空工单号/SN,进入型号筛选模式' }, + { name: '工单号', source: '手工填写。', purpose: '直接查某工单的生产流程卡主卡', fill: '回车或点查询' }, + { name: '成品SN', source: '手工填写。', purpose: '查某成品的 SN 追溯卡', fill: '回车或点查询' }, + { name: '时间范围', source: '日历选择(月范围)。', purpose: '仅在型号筛选模式下过滤工单列表', fill: '默认上月;不选=全部时间' }, + { name: '工序实绩-审核人', source: '自动带出该工序的审核签字人(AUDITOR)及审核时间。', purpose: '工序级审核放行留痕', fill: '无则显示“-”' } + ] +} + +export const helpAudit = { + title: '待审核签字(工序级审核)', + overview: + '本页是审核人的「待审任务」工作台:列出已满足前置签字条件的工艺步骤(操作工已签字;若该步骤配置了「需检验员签字」则检验员须 OK),由具审核角色(如班组长/工艺员)的人员复核。\n\n审核定位在**工序级、由工艺配置决定**:工艺步骤是否需审核(process_step.need_audit)及其审核角色(audit_role)在「工艺」页配置。\n\n两种操作:\n· 审核通过(result=OK)→ 该步骤放行;\n· 退回重做(result=NG)→ 撤销该步骤已有的操作工/检验员签字,退回操作工重做(进入新一轮签字)。\n\n审核只记录「审核人 + 审核时间」,不引入签名图片;签字区在「生产流程卡」页照实展示。', + fields: [ + { name: '工单号 / 工件SN', source: '筛选条件。', purpose: '缩小待审范围', fill: '可空=全部' }, + { name: '操作工 / 操作工签字时间', source: '自动带出该步骤操作工签字人及时间。', purpose: '审核前确认是谁做的', fill: '只读' }, + { name: '审核通过', source: '按钮。POST /signs/auditor(result=OK)。', purpose: '审核放行', fill: '点击即生效并刷新列表' }, + { name: '退回重做', source: '按钮。需填退回原因,POST /signs/auditor(result=NG)。', purpose: '审核不通过,退回操作工重做', fill: '撤销该步骤已有签字,进入新一轮' } + ] +} + +export const helpProductProcess = { + title: '产品工艺(产品级工艺定义)', + overview: + '本页定义"某个产品该按什么顺序经过哪些工艺":一条产品工艺 = 某产品 + 有序的工艺清单(选择顺序即执行顺序)。\n\n与「工艺」页的关系:工艺(工位级流程图+工艺步骤)描述"一个工位怎么干",是本页的组成单元;产品工艺把它们按产品组织起来,只选工艺和顺序、**不绑工位**。\n\n与工单的关系:新建工单选完产品后自动带出默认产品工艺,并把每道工艺当前绑定的全部启用工位自动填入工单「工艺组合」——组合是快照、可手动增删;与产品工艺的个数/顺序不符时保存会有**警告提示(不阻断)**。工单保存后与产品工艺互不影响。\n\n约束:同一工艺不能在同一产品工艺内重复;每个产品可建多条(如常规/高配),其中一条可设为默认;被工单引用过的产品工艺**只读**(禁编辑禁删),只能停用+新建,历史工单可反查当时定义。列表"可执行"列实时反映工位绑定情况:某道工艺暂无启用的绑定工位、或工位顺序冲突时显示"待就绪"及原因。', + fields: [ + { name: '产品', source: '下拉选择,来自「物料档案」(WMS 物料主数据)。', purpose: '这条产品工艺属于哪个产品', fill: '必选' }, + { name: '工艺名称', source: '手工填写。', purpose: '区分同产品的多条产品工艺(如 常规/高配)', fill: '必填' }, + { name: '工艺顺序', source: '先勾选「加入」,再用上移/下移按钮排顺序(列表从上到下=执行顺序)。', purpose: '该产品依次经过哪些工艺', fill: '至少一道;同一工艺不可重复加入' }, + { name: '路线卡', source: '按钮。服务端渲染可打印 HTML(新窗口打开,可另存为 PDF)。', purpose: '产品级定义层卡:工艺路线+各工艺步骤配置(含审核开关)+物料清单+检验卡项', fill: '只读展示当前定义;工单实绩看「生产流程卡」' }, + { name: '设为默认', source: '勾选。', purpose: '新建工单选完产品自动带出', fill: '每产品至多一条默认,设新自动取消旧' }, + { name: '可执行', source: '实时反查「工位绑定」:每道工艺是否有启用的绑定工位、顺序是否可满足。', purpose: '保存前预检,建工单时不会推导出残缺组合', fill: '只读;待就绪时悬停看原因' }, + { name: '被工单引用', source: '统计 product_process_id 指向本条的工单数。', purpose: '只读守卫提示', fill: '>0 时禁编辑/删除,只能停用' } ] } diff --git a/bj_power_mes/frontend/src/layouts/MainLayout.vue b/bj_power_mes/frontend/src/layouts/MainLayout.vue index bef8816..38e2a4e 100644 --- a/bj_power_mes/frontend/src/layouts/MainLayout.vue +++ b/bj_power_mes/frontend/src/layouts/MainLayout.vue @@ -144,12 +144,14 @@ const menuGroups = [ { code: 'produce.trace', name: '工件追溯', path: '/trace', icon: Search }, { code: 'produce.virtualstation', name: '虚拟工位作业', path: '/virtual-station', icon: Goods }, { code: 'produce.processcard', name: '生产流程卡', path: '/process-card', icon: Tickets }, + { code: 'produce.audit', name: '待审核签字', path: '/audit-pending', icon: CircleCheck }, { code: 'sys.inspect', name: '巡检终端', path: '/inspect', icon: CircleCheck } ] }, { title: '基础配置', icon: Box, children: [ { code: 'produce.processflow', name: '工艺', path: '/process-flow', icon: Operation }, + { code: 'produce.productprocess', name: '产品工艺', path: '/product-process', icon: Goods }, { code: 'produce.station', name: '工位绑定', path: '/station', icon: Link }, { code: 'produce.dock', name: '接驳台维护', path: '/dock', icon: Aim }, { code: 'produce.product', name: '物料档案', path: '/product-type', icon: Box } diff --git a/bj_power_mes/frontend/src/pages/AccountManage.vue b/bj_power_mes/frontend/src/pages/AccountManage.vue index c57b315..3c541e6 100644 --- a/bj_power_mes/frontend/src/pages/AccountManage.vue +++ b/bj_power_mes/frontend/src/pages/AccountManage.vue @@ -84,7 +84,7 @@ - + diff --git a/bj_power_mes/frontend/src/pages/AlertCenter.vue b/bj_power_mes/frontend/src/pages/AlertCenter.vue index 0129f31..df5180a 100644 --- a/bj_power_mes/frontend/src/pages/AlertCenter.vue +++ b/bj_power_mes/frontend/src/pages/AlertCenter.vue @@ -77,7 +77,7 @@ const unread = ref(0) const statusFilter = ref('all') const typeFilter = ref('') const orderNo = ref('') -const startDate = ref(todayStr()) // 开始时间默认当天 +const startDate = ref(monthAgoStr()) // 开始时间默认一个月前 const endDate = ref('') // 结束时间默认空 function todayStr() { @@ -85,6 +85,13 @@ function todayStr() { const p = (n) => String(n).padStart(2, '0') return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}` } +// 默认开始时间:一个月前(预警默认看近一月) +function monthAgoStr() { + const d = new Date() + d.setMonth(d.getMonth() - 1) + const p = (n) => String(n).padStart(2, '0') + return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}` +} function fmtTime(v) { if (!v) return '-' const d = new Date(v) @@ -138,7 +145,7 @@ function reset() { statusFilter.value = 'all' typeFilter.value = '' orderNo.value = '' - startDate.value = todayStr() + startDate.value = monthAgoStr() endDate.value = '' page.value = 1 loadAlerts() diff --git a/bj_power_mes/frontend/src/pages/AuditPending.vue b/bj_power_mes/frontend/src/pages/AuditPending.vue new file mode 100644 index 0000000..d071fa9 --- /dev/null +++ b/bj_power_mes/frontend/src/pages/AuditPending.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/bj_power_mes/frontend/src/pages/DailyPlan.vue b/bj_power_mes/frontend/src/pages/DailyPlan.vue index b32f273..2e0547f 100644 --- a/bj_power_mes/frontend/src/pages/DailyPlan.vue +++ b/bj_power_mes/frontend/src/pages/DailyPlan.vue @@ -11,7 +11,8 @@ - + @@ -19,7 +20,7 @@ - + @@ -176,7 +177,9 @@ - + @@ -316,7 +319,6 @@ const allRows = ref([]) const total = ref(0) const page = ref(1) const pageSize = ref(50) -const workOrders = ref([]) const productTypes = ref([]) const dialog = reactive({ show: false, id: 0, orderNo: '', planDate: '', planRange: [], mode: 'AVG', planQty: 1, productType: '', productCode: '', productName: '', woQty: '', woStart: '', woDue: '', stationPlanQty: {}, combination: [] }) @@ -363,22 +365,54 @@ const woStatusText = (s) => woStatusMap[s] || s async function loadStations() { const sts = (await request.get('/stations')) || [] - const dm = {}; const nm = {} - sts.forEach((s) => { dm[s.stationNo] = s.dockCode || ''; nm[s.stationNo] = s.name }) - stationDockMap.value = dm + const nm = {} + sts.forEach((s) => { nm[s.stationNo] = s.name }) stationNameMap.value = nm + // 接驳台真源 = dock 表(一个工位可配 R1/R2 多个接驳台),按 station_no 聚合为 stationNo → [dockCode] + const docks = (await request.get('/docks')) || [] + const dm = {} + docks.forEach((d) => { + if (!d.dockCode) return + if (!dm[d.stationNo]) dm[d.stationNo] = [] + if (!dm[d.stationNo].includes(d.dockCode)) dm[d.stationNo].push(d.dockCode) + }) + stationDockMap.value = dm } const allDockCodes = computed(() => { const set = {} - Object.values(stationDockMap.value).forEach((d) => { if (d) set[d] = true }) + Object.values(stationDockMap.value).forEach((arr) => { (arr || []).forEach((d) => { if (d) set[d] = true }) }) return Object.keys(set).sort() }) +// 工单下拉:远程搜索(keyword+limit=50,防数据炸弹);选中项不在池中时按单号精确补拉 +const workOrders = ref([]) +const woSearching = ref(false) +async function searchWorkOrders(kw) { + woSearching.value = true + try { + const data = await request.get('/work-orders', { params: { keyword: kw || '', limit: 50 } }) + workOrders.value = Array.isArray(data) ? data : [] + } catch { workOrders.value = [] } finally { woSearching.value = false } +} +// 同步取产品名(行内展示用);池未命中返回空,由 fetchPage 后的补池异步填充 function productNameOf(orderNo) { const wo = workOrders.value.find((w) => w.workOrderNo === orderNo) if (!wo) return '' const pt = productTypes.value.find((p) => p.id === wo.productTypeId) return pt ? (pt.name + (pt.code ? ' / ' + pt.code : '')) : '' } +// 精确补拉某工单进池(find 未命中时兜底,保证派生信息不丢) +async function ensureWorkOrder(orderNo) { + if (!orderNo) return null + let wo = workOrders.value.find((w) => w.workOrderNo === orderNo) + if (wo) return wo + try { + const data = await request.get('/work-orders', { params: { orderNo } }) + const arr = Array.isArray(data) ? data : [] + wo = arr.find((w) => w.workOrderNo === orderNo) || null + if (wo) workOrders.value.push(wo) + } catch { /* 保持 null */ } + return wo +} function productNameOfUnplanned(u) { const pt = productTypes.value.find((p) => p.id === u.productTypeId) return pt ? (pt.name + (pt.code ? ' / ' + pt.code : '')) : '' @@ -393,6 +427,10 @@ async function fetchPage() { })) || {} allRows.value = res.list || [] total.value = res.total || 0 + // 远程搜索模式下补池:把本页出现但不在池中的工单精确补拉(保证产品名/派生信息完整) + const missing = [...new Set(allRows.value.map((r) => r.orderNo).filter(Boolean))] + .filter((no) => !workOrders.value.some((w) => w.workOrderNo === no)) + for (const no of missing.slice(0, 20)) await ensureWorkOrder(no) } // 查询条件变化 → 回到第 1 页重新拉取(共用一次请求,切 Tab 不重拉) async function load() { @@ -404,13 +442,14 @@ function onPageChange(p) { fetchPage() } -// 该行送达接驳台:由工单工艺组合的工位号 → 接驳台编码去重派生 +// 该行送达接驳台:由工单工艺组合的工位号 → dock 表接驳台编码去重派生(支持一工位 R1/R2 多个接驳台) function docksOf(row) { const comb = row.flowCombination || [] const seen = {}; const ds = [] comb.map((c) => c.stationNo).sort((a, b) => a - b).forEach((n) => { - const dc = stationDockMap.value[n] - if (dc && !seen[dc]) { seen[dc] = true; ds.push(dc) } + ;(stationDockMap.value[n] || []).forEach((dc) => { + if (dc && !seen[dc]) { seen[dc] = true; ds.push(dc) } + }) }) return ds } @@ -522,8 +561,8 @@ function loadAlloc() { Object.keys(alloc).forEach((k) => { delete alloc[k] }) Object.assign(alloc, init) } -function loadWorkOrderInfo() { - const wo = workOrders.value.find((w) => w.workOrderNo === dialog.orderNo) +async function loadWorkOrderInfo() { + const wo = await ensureWorkOrder(dialog.orderNo) if (!wo) { dialog.productType = ''; dialog.productCode = ''; dialog.productName = ''; dialog.woQty = '' dialog.combination = []; dialog.woStart = ''; dialog.woDue = '' @@ -537,12 +576,16 @@ function loadWorkOrderInfo() { dialog.productType = pt ? (pt.name + (pt.code ? ' / ' + pt.code : '')) : '' dialog.woStart = wo.planStart ? String(wo.planStart).slice(0, 10) : '' dialog.woDue = wo.dueDate ? String(wo.dueDate).slice(0, 10) : '' - if (!dialog.id && (dialog.woStart || dialog.woDue)) { - dialog.planRange = [dialog.woStart || dialog.woDue, dialog.woDue || dialog.woStart] + if (!dialog.id) { + const today = todayStr() + const start = dialog.woStart || today + const end = dialog.woDue || addDays(7) + // 起期不晚于止期;若起期晚于止期(如止期已过期)则退化为单日,避免 el-date-picker 报错 + dialog.planRange = start <= end ? [start, end] : [end, end] } } -function onOrderChange() { - loadWorkOrderInfo() +async function onOrderChange() { + await loadWorkOrderInfo() if (dialog.id && (dialog.woStart || dialog.woDue)) dialog.planDate = dialog.woStart || dialog.woDue } function openAdd(presetOrderNo) { @@ -604,7 +647,7 @@ async function toggleStatus(row) { fetchPage() } onMounted(async () => { - workOrders.value = (await request.get('/work-orders')) || [] + searchWorkOrders('') // 首屏只拉最近 50 条供下拉,其余走远程搜索 productTypes.value = (await request.get('/product-types')) || [] await loadStations() await load() diff --git a/bj_power_mes/frontend/src/pages/Inspect.vue b/bj_power_mes/frontend/src/pages/Inspect.vue index d178d2b..74b3893 100644 --- a/bj_power_mes/frontend/src/pages/Inspect.vue +++ b/bj_power_mes/frontend/src/pages/Inspect.vue @@ -57,7 +57,9 @@ - + @@ -103,7 +105,9 @@ - + @@ -459,7 +463,8 @@ const categoryOptions = [ { v: 'POINT', l: '工位点检' }, { v: 'PROCESS', l: '过程巡检' }, { v: 'DONE', l: '完工确认' }, - { v: 'ALARM', l: '异常上报' } + { v: 'ALARM', l: '异常上报' }, + { v: 'FINAL', l: '完工检' } ] const categoryText = (c) => (categoryOptions.find((x) => x.v === c) || {}).l || c || '-' // OK/NG 为数据枚举值,界面统一显示中文 @@ -482,13 +487,15 @@ const genLoading = ref(false) const done = reactive({ orderNo: '', order: null, confirmed: false, remark: '' }) const alarm = reactive({ stationNo: 1, items: [], photo: '', remark: '' }) -// ---------- 工单下拉(GET /work-orders 返回 {list:[...]}) ---------- +// ---------- 工单下拉(GET /work-orders 返回数组;远程搜索 keyword+limit=50,防数据炸弹) ---------- const workOrders = ref([]) -async function loadWorkOrders() { +const woSearching = ref(false) +async function searchWorkOrders(kw) { + woSearching.value = true try { - const data = await request.get('/work-orders') - workOrders.value = (data && Array.isArray(data.list) ? data.list : data) || [] - } catch { workOrders.value = [] } + const data = await request.get('/work-orders', { params: { keyword: kw || '', limit: 50 } }) + workOrders.value = Array.isArray(data) ? data : [] + } catch { workOrders.value = [] } finally { woSearching.value = false } } function onProcessOrder(no) { process.order = workOrders.value.find((w) => w.workOrderNo === no) || null } function onDoneOrder(no) { done.order = workOrders.value.find((w) => w.workOrderNo === no) || null } @@ -811,7 +818,7 @@ async function confirmPendingAudit() { // 切到「待签任务」页签时刷新列表(签字队列需实时) function onTabChange(name) { if (name === 'PENDING') loadPending() } -onMounted(async () => { loadWorkOrders(); loadRecords(); stationNos.value = await loadStationNos() }) +onMounted(async () => { searchWorkOrders(''); loadRecords(); stationNos.value = await loadStationNos() }) diff --git a/bj_power_mes/frontend/src/pages/ProcessFlow.vue b/bj_power_mes/frontend/src/pages/ProcessFlow.vue index 667c784..7ad933e 100644 --- a/bj_power_mes/frontend/src/pages/ProcessFlow.vue +++ b/bj_power_mes/frontend/src/pages/ProcessFlow.vue @@ -4,6 +4,9 @@ + + + 查询 @@ -15,6 +18,12 @@ + + +