diff --git a/bj_power_mes/ent/bomitem.go b/bj_power_mes/ent/bomitem.go index e298bcd..9ae1e92 100644 --- a/bj_power_mes/ent/bomitem.go +++ b/bj_power_mes/ent/bomitem.go @@ -20,6 +20,8 @@ type BomItem struct { ID int `json:"id,omitempty"` // 产品编码 ProductCode string `json:"productCode,omitempty"` + // BOM名称:同一型号多份并存(如 厂家A/厂家B/含半成品),工单按名选用 + BomName string `json:"bomName,omitempty"` // 物料编码 MaterialCode string `json:"materialCode,omitempty"` // MaterialName holds the value of the "materialName" field. @@ -56,7 +58,7 @@ func (*BomItem) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullFloat64) case bomitem.FieldID, bomitem.FieldProcessCode: values[i] = new(sql.NullInt64) - case bomitem.FieldProductCode, bomitem.FieldMaterialCode, bomitem.FieldMaterialName, bomitem.FieldSpec, bomitem.FieldUnit, bomitem.FieldManageMode: + case bomitem.FieldProductCode, bomitem.FieldBomName, bomitem.FieldMaterialCode, bomitem.FieldMaterialName, bomitem.FieldSpec, bomitem.FieldUnit, bomitem.FieldManageMode: values[i] = new(sql.NullString) case bomitem.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -87,6 +89,12 @@ func (_m *BomItem) assignValues(columns []string, values []any) error { } else if value.Valid { _m.ProductCode = value.String } + case bomitem.FieldBomName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field bomName", values[i]) + } else if value.Valid { + _m.BomName = value.String + } case bomitem.FieldMaterialCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field materialCode", values[i]) @@ -194,6 +202,9 @@ func (_m *BomItem) String() string { builder.WriteString("productCode=") builder.WriteString(_m.ProductCode) builder.WriteString(", ") + builder.WriteString("bomName=") + builder.WriteString(_m.BomName) + builder.WriteString(", ") builder.WriteString("materialCode=") builder.WriteString(_m.MaterialCode) builder.WriteString(", ") diff --git a/bj_power_mes/ent/bomitem/bomitem.go b/bj_power_mes/ent/bomitem/bomitem.go index 45a34ee..f361409 100644 --- a/bj_power_mes/ent/bomitem/bomitem.go +++ b/bj_power_mes/ent/bomitem/bomitem.go @@ -15,6 +15,8 @@ const ( FieldID = "id" // FieldProductCode holds the string denoting the productcode field in the database. FieldProductCode = "product_code" + // FieldBomName holds the string denoting the bomname field in the database. + FieldBomName = "bom_name" // FieldMaterialCode holds the string denoting the materialcode field in the database. FieldMaterialCode = "material_code" // FieldMaterialName holds the string denoting the materialname field in the database. @@ -45,6 +47,7 @@ const ( var Columns = []string{ FieldID, FieldProductCode, + FieldBomName, FieldMaterialCode, FieldMaterialName, FieldSpec, @@ -73,6 +76,10 @@ var ( DefaultProductCode string // ProductCodeValidator is a validator for the "productCode" field. It is called by the builders before save. ProductCodeValidator func(string) error + // DefaultBomName holds the default value on creation for the "bomName" field. + DefaultBomName string + // BomNameValidator is a validator for the "bomName" field. It is called by the builders before save. + BomNameValidator func(string) error // MaterialCodeValidator is a validator for the "materialCode" field. It is called by the builders before save. MaterialCodeValidator func(string) error // DefaultMaterialName holds the default value on creation for the "materialName" field. @@ -118,6 +125,11 @@ func ByProductCode(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldProductCode, opts...).ToFunc() } +// ByBomName orders the results by the bomName field. +func ByBomName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBomName, opts...).ToFunc() +} + // ByMaterialCode orders the results by the materialCode field. func ByMaterialCode(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldMaterialCode, opts...).ToFunc() diff --git a/bj_power_mes/ent/bomitem/where.go b/bj_power_mes/ent/bomitem/where.go index 944f34a..f92e296 100644 --- a/bj_power_mes/ent/bomitem/where.go +++ b/bj_power_mes/ent/bomitem/where.go @@ -59,6 +59,11 @@ func ProductCode(v string) predicate.BomItem { return predicate.BomItem(sql.FieldEQ(FieldProductCode, v)) } +// BomName applies equality check predicate on the "bomName" field. It's identical to BomNameEQ. +func BomName(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldEQ(FieldBomName, v)) +} + // MaterialCode applies equality check predicate on the "materialCode" field. It's identical to MaterialCodeEQ. func MaterialCode(v string) predicate.BomItem { return predicate.BomItem(sql.FieldEQ(FieldMaterialCode, v)) @@ -174,6 +179,71 @@ func ProductCodeContainsFold(v string) predicate.BomItem { return predicate.BomItem(sql.FieldContainsFold(FieldProductCode, v)) } +// BomNameEQ applies the EQ predicate on the "bomName" field. +func BomNameEQ(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldEQ(FieldBomName, v)) +} + +// BomNameNEQ applies the NEQ predicate on the "bomName" field. +func BomNameNEQ(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldNEQ(FieldBomName, v)) +} + +// BomNameIn applies the In predicate on the "bomName" field. +func BomNameIn(vs ...string) predicate.BomItem { + return predicate.BomItem(sql.FieldIn(FieldBomName, vs...)) +} + +// BomNameNotIn applies the NotIn predicate on the "bomName" field. +func BomNameNotIn(vs ...string) predicate.BomItem { + return predicate.BomItem(sql.FieldNotIn(FieldBomName, vs...)) +} + +// BomNameGT applies the GT predicate on the "bomName" field. +func BomNameGT(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldGT(FieldBomName, v)) +} + +// BomNameGTE applies the GTE predicate on the "bomName" field. +func BomNameGTE(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldGTE(FieldBomName, v)) +} + +// BomNameLT applies the LT predicate on the "bomName" field. +func BomNameLT(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldLT(FieldBomName, v)) +} + +// BomNameLTE applies the LTE predicate on the "bomName" field. +func BomNameLTE(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldLTE(FieldBomName, v)) +} + +// BomNameContains applies the Contains predicate on the "bomName" field. +func BomNameContains(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldContains(FieldBomName, v)) +} + +// BomNameHasPrefix applies the HasPrefix predicate on the "bomName" field. +func BomNameHasPrefix(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldHasPrefix(FieldBomName, v)) +} + +// BomNameHasSuffix applies the HasSuffix predicate on the "bomName" field. +func BomNameHasSuffix(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldHasSuffix(FieldBomName, v)) +} + +// BomNameEqualFold applies the EqualFold predicate on the "bomName" field. +func BomNameEqualFold(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldEqualFold(FieldBomName, v)) +} + +// BomNameContainsFold applies the ContainsFold predicate on the "bomName" field. +func BomNameContainsFold(v string) predicate.BomItem { + return predicate.BomItem(sql.FieldContainsFold(FieldBomName, v)) +} + // MaterialCodeEQ applies the EQ predicate on the "materialCode" field. func MaterialCodeEQ(v string) predicate.BomItem { return predicate.BomItem(sql.FieldEQ(FieldMaterialCode, v)) diff --git a/bj_power_mes/ent/bomitem_create.go b/bj_power_mes/ent/bomitem_create.go index 6766045..d1dfdad 100644 --- a/bj_power_mes/ent/bomitem_create.go +++ b/bj_power_mes/ent/bomitem_create.go @@ -34,6 +34,20 @@ func (_c *BomItemCreate) SetNillableProductCode(v *string) *BomItemCreate { return _c } +// SetBomName sets the "bomName" field. +func (_c *BomItemCreate) SetBomName(v string) *BomItemCreate { + _c.mutation.SetBomName(v) + return _c +} + +// SetNillableBomName sets the "bomName" field if the given value is not nil. +func (_c *BomItemCreate) SetNillableBomName(v *string) *BomItemCreate { + if v != nil { + _c.SetBomName(*v) + } + return _c +} + // SetMaterialCode sets the "materialCode" field. func (_c *BomItemCreate) SetMaterialCode(v string) *BomItemCreate { _c.mutation.SetMaterialCode(v) @@ -217,6 +231,10 @@ func (_c *BomItemCreate) defaults() { v := bomitem.DefaultProductCode _c.mutation.SetProductCode(v) } + if _, ok := _c.mutation.BomName(); !ok { + v := bomitem.DefaultBomName + _c.mutation.SetBomName(v) + } if _, ok := _c.mutation.MaterialName(); !ok { v := bomitem.DefaultMaterialName _c.mutation.SetMaterialName(v) @@ -265,6 +283,14 @@ func (_c *BomItemCreate) check() error { return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "BomItem.productCode": %w`, err)} } } + if _, ok := _c.mutation.BomName(); !ok { + return &ValidationError{Name: "bomName", err: errors.New(`ent: missing required field "BomItem.bomName"`)} + } + if v, ok := _c.mutation.BomName(); ok { + if err := bomitem.BomNameValidator(v); err != nil { + return &ValidationError{Name: "bomName", err: fmt.Errorf(`ent: validator failed for field "BomItem.bomName": %w`, err)} + } + } if _, ok := _c.mutation.MaterialCode(); !ok { return &ValidationError{Name: "materialCode", err: errors.New(`ent: missing required field "BomItem.materialCode"`)} } @@ -361,6 +387,10 @@ func (_c *BomItemCreate) createSpec() (*BomItem, *sqlgraph.CreateSpec) { _spec.SetField(bomitem.FieldProductCode, field.TypeString, value) _node.ProductCode = value } + if value, ok := _c.mutation.BomName(); ok { + _spec.SetField(bomitem.FieldBomName, field.TypeString, value) + _node.BomName = value + } if value, ok := _c.mutation.MaterialCode(); ok { _spec.SetField(bomitem.FieldMaterialCode, field.TypeString, value) _node.MaterialCode = value diff --git a/bj_power_mes/ent/bomitem_update.go b/bj_power_mes/ent/bomitem_update.go index bbbc6a8..0c9ab34 100644 --- a/bj_power_mes/ent/bomitem_update.go +++ b/bj_power_mes/ent/bomitem_update.go @@ -43,6 +43,20 @@ func (_u *BomItemUpdate) SetNillableProductCode(v *string) *BomItemUpdate { return _u } +// SetBomName sets the "bomName" field. +func (_u *BomItemUpdate) SetBomName(v string) *BomItemUpdate { + _u.mutation.SetBomName(v) + return _u +} + +// SetNillableBomName sets the "bomName" field if the given value is not nil. +func (_u *BomItemUpdate) SetNillableBomName(v *string) *BomItemUpdate { + if v != nil { + _u.SetBomName(*v) + } + return _u +} + // SetMaterialCode sets the "materialCode" field. func (_u *BomItemUpdate) SetMaterialCode(v string) *BomItemUpdate { _u.mutation.SetMaterialCode(v) @@ -254,6 +268,11 @@ func (_u *BomItemUpdate) check() error { return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "BomItem.productCode": %w`, err)} } } + if v, ok := _u.mutation.BomName(); ok { + if err := bomitem.BomNameValidator(v); err != nil { + return &ValidationError{Name: "bomName", err: fmt.Errorf(`ent: validator failed for field "BomItem.bomName": %w`, err)} + } + } if v, ok := _u.mutation.MaterialCode(); ok { if err := bomitem.MaterialCodeValidator(v); err != nil { return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "BomItem.materialCode": %w`, err)} @@ -303,6 +322,9 @@ func (_u *BomItemUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.ProductCode(); ok { _spec.SetField(bomitem.FieldProductCode, field.TypeString, value) } + if value, ok := _u.mutation.BomName(); ok { + _spec.SetField(bomitem.FieldBomName, field.TypeString, value) + } if value, ok := _u.mutation.MaterialCode(); ok { _spec.SetField(bomitem.FieldMaterialCode, field.TypeString, value) } @@ -389,6 +411,20 @@ func (_u *BomItemUpdateOne) SetNillableProductCode(v *string) *BomItemUpdateOne return _u } +// SetBomName sets the "bomName" field. +func (_u *BomItemUpdateOne) SetBomName(v string) *BomItemUpdateOne { + _u.mutation.SetBomName(v) + return _u +} + +// SetNillableBomName sets the "bomName" field if the given value is not nil. +func (_u *BomItemUpdateOne) SetNillableBomName(v *string) *BomItemUpdateOne { + if v != nil { + _u.SetBomName(*v) + } + return _u +} + // SetMaterialCode sets the "materialCode" field. func (_u *BomItemUpdateOne) SetMaterialCode(v string) *BomItemUpdateOne { _u.mutation.SetMaterialCode(v) @@ -613,6 +649,11 @@ func (_u *BomItemUpdateOne) check() error { return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "BomItem.productCode": %w`, err)} } } + if v, ok := _u.mutation.BomName(); ok { + if err := bomitem.BomNameValidator(v); err != nil { + return &ValidationError{Name: "bomName", err: fmt.Errorf(`ent: validator failed for field "BomItem.bomName": %w`, err)} + } + } if v, ok := _u.mutation.MaterialCode(); ok { if err := bomitem.MaterialCodeValidator(v); err != nil { return &ValidationError{Name: "materialCode", err: fmt.Errorf(`ent: validator failed for field "BomItem.materialCode": %w`, err)} @@ -679,6 +720,9 @@ func (_u *BomItemUpdateOne) sqlSave(ctx context.Context) (_node *BomItem, err er if value, ok := _u.mutation.ProductCode(); ok { _spec.SetField(bomitem.FieldProductCode, field.TypeString, value) } + if value, ok := _u.mutation.BomName(); ok { + _spec.SetField(bomitem.FieldBomName, field.TypeString, value) + } if value, ok := _u.mutation.MaterialCode(); ok { _spec.SetField(bomitem.FieldMaterialCode, field.TypeString, value) } diff --git a/bj_power_mes/ent/migrate/schema.go b/bj_power_mes/ent/migrate/schema.go index 25b42c9..7956387 100644 --- a/bj_power_mes/ent/migrate/schema.go +++ b/bj_power_mes/ent/migrate/schema.go @@ -37,6 +37,7 @@ var ( WorkOrderBomColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt, Increment: true}, {Name: "product_code", Type: field.TypeString, Size: 64, Default: ""}, + {Name: "bom_name", Type: field.TypeString, Size: 64, Default: "默认"}, {Name: "material_code", Type: field.TypeString, Size: 64}, {Name: "material_name", Type: field.TypeString, Size: 128, Default: ""}, {Name: "spec", Type: field.TypeString, Size: 128, Default: ""}, @@ -61,9 +62,9 @@ var ( Columns: []*schema.Column{WorkOrderBomColumns[1]}, }, { - Name: "bomitem_product_code_material_code", + Name: "bomitem_product_code_bom_name_material_code", Unique: true, - Columns: []*schema.Column{WorkOrderBomColumns[1], WorkOrderBomColumns[2]}, + Columns: []*schema.Column{WorkOrderBomColumns[1], WorkOrderBomColumns[2], WorkOrderBomColumns[3]}, }, }, } @@ -647,6 +648,7 @@ var ( {Name: "can_login_workstation", Type: field.TypeBool, Default: false}, {Name: "workstation_password", Type: field.TypeString, Nullable: true, Size: 128}, {Name: "status", Type: field.TypeString, Size: 20, Default: "ENABLED"}, + {Name: "last_login_at", Type: field.TypeInt64, Nullable: true}, {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime, Nullable: true}, } @@ -704,6 +706,7 @@ var ( {Name: "work_order_no", Type: field.TypeString, Size: 64}, {Name: "product_type_id", Type: field.TypeInt}, {Name: "product_code", Type: field.TypeString, Size: 64, Default: ""}, + {Name: "bom_name", Type: field.TypeString, Size: 64, Default: "默认"}, {Name: "product_name", Type: field.TypeString, Size: 128, Default: ""}, {Name: "quantity", Type: field.TypeInt, Default: 1}, {Name: "finished_num", Type: field.TypeInt, Default: 0}, @@ -731,7 +734,7 @@ var ( { Name: "workorder_status", Unique: false, - Columns: []*schema.Column{WorkOrderColumns[9]}, + Columns: []*schema.Column{WorkOrderColumns[10]}, }, { Name: "workorder_product_type_id", diff --git a/bj_power_mes/ent/mutation.go b/bj_power_mes/ent/mutation.go index c47dd05..4aa17d3 100644 --- a/bj_power_mes/ent/mutation.go +++ b/bj_power_mes/ent/mutation.go @@ -813,6 +813,7 @@ type BomItemMutation struct { typ string id *int productCode *string + bomName *string materialCode *string materialName *string spec *string @@ -975,6 +976,42 @@ func (m *BomItemMutation) ResetProductCode() { m.productCode = nil } +// SetBomName sets the "bomName" field. +func (m *BomItemMutation) SetBomName(s string) { + m.bomName = &s +} + +// BomName returns the value of the "bomName" field in the mutation. +func (m *BomItemMutation) BomName() (r string, exists bool) { + v := m.bomName + if v == nil { + return + } + return *v, true +} + +// OldBomName returns the old "bomName" field's value of the BomItem entity. +// If the BomItem object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BomItemMutation) OldBomName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBomName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBomName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBomName: %w", err) + } + return oldValue.BomName, nil +} + +// ResetBomName resets all changes to the "bomName" field. +func (m *BomItemMutation) ResetBomName() { + m.bomName = nil +} + // SetMaterialCode sets the "materialCode" field. func (m *BomItemMutation) SetMaterialCode(s string) { m.materialCode = &s @@ -1514,10 +1551,13 @@ func (m *BomItemMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *BomItemMutation) Fields() []string { - fields := make([]string, 0, 12) + fields := make([]string, 0, 13) if m.productCode != nil { fields = append(fields, bomitem.FieldProductCode) } + if m.bomName != nil { + fields = append(fields, bomitem.FieldBomName) + } if m.materialCode != nil { fields = append(fields, bomitem.FieldMaterialCode) } @@ -1561,6 +1601,8 @@ func (m *BomItemMutation) Field(name string) (ent.Value, bool) { switch name { case bomitem.FieldProductCode: return m.ProductCode() + case bomitem.FieldBomName: + return m.BomName() case bomitem.FieldMaterialCode: return m.MaterialCode() case bomitem.FieldMaterialName: @@ -1594,6 +1636,8 @@ func (m *BomItemMutation) OldField(ctx context.Context, name string) (ent.Value, switch name { case bomitem.FieldProductCode: return m.OldProductCode(ctx) + case bomitem.FieldBomName: + return m.OldBomName(ctx) case bomitem.FieldMaterialCode: return m.OldMaterialCode(ctx) case bomitem.FieldMaterialName: @@ -1632,6 +1676,13 @@ func (m *BomItemMutation) SetField(name string, value ent.Value) error { } m.SetProductCode(v) return nil + case bomitem.FieldBomName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBomName(v) + return nil case bomitem.FieldMaterialCode: v, ok := value.(string) if !ok { @@ -1821,6 +1872,9 @@ func (m *BomItemMutation) ResetField(name string) error { case bomitem.FieldProductCode: m.ResetProductCode() return nil + case bomitem.FieldBomName: + m.ResetBomName() + return nil case bomitem.FieldMaterialCode: m.ResetMaterialCode() return nil @@ -15929,6 +15983,8 @@ type UserMutation struct { canLoginWorkstation *bool workstationPassword *string status *string + lastLoginAt *int64 + addlastLoginAt *int64 createdAt *time.Time updatedAt *time.Time clearedFields map[string]struct{} @@ -16340,6 +16396,76 @@ func (m *UserMutation) ResetStatus() { m.status = nil } +// SetLastLoginAt sets the "lastLoginAt" field. +func (m *UserMutation) SetLastLoginAt(i int64) { + m.lastLoginAt = &i + m.addlastLoginAt = nil +} + +// LastLoginAt returns the value of the "lastLoginAt" field in the mutation. +func (m *UserMutation) LastLoginAt() (r int64, exists bool) { + v := m.lastLoginAt + if v == nil { + return + } + return *v, true +} + +// OldLastLoginAt returns the old "lastLoginAt" field's value of the User entity. +// If the User 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 *UserMutation) OldLastLoginAt(ctx context.Context) (v *int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastLoginAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastLoginAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastLoginAt: %w", err) + } + return oldValue.LastLoginAt, nil +} + +// AddLastLoginAt adds i to the "lastLoginAt" field. +func (m *UserMutation) AddLastLoginAt(i int64) { + if m.addlastLoginAt != nil { + *m.addlastLoginAt += i + } else { + m.addlastLoginAt = &i + } +} + +// AddedLastLoginAt returns the value that was added to the "lastLoginAt" field in this mutation. +func (m *UserMutation) AddedLastLoginAt() (r int64, exists bool) { + v := m.addlastLoginAt + if v == nil { + return + } + return *v, true +} + +// ClearLastLoginAt clears the value of the "lastLoginAt" field. +func (m *UserMutation) ClearLastLoginAt() { + m.lastLoginAt = nil + m.addlastLoginAt = nil + m.clearedFields[user.FieldLastLoginAt] = struct{}{} +} + +// LastLoginAtCleared returns if the "lastLoginAt" field was cleared in this mutation. +func (m *UserMutation) LastLoginAtCleared() bool { + _, ok := m.clearedFields[user.FieldLastLoginAt] + return ok +} + +// ResetLastLoginAt resets all changes to the "lastLoginAt" field. +func (m *UserMutation) ResetLastLoginAt() { + m.lastLoginAt = nil + m.addlastLoginAt = nil + delete(m.clearedFields, user.FieldLastLoginAt) +} + // SetCreatedAt sets the "createdAt" field. func (m *UserMutation) SetCreatedAt(t time.Time) { m.createdAt = &t @@ -16459,7 +16585,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 9) + fields := make([]string, 0, 10) if m.username != nil { fields = append(fields, user.FieldUsername) } @@ -16481,6 +16607,9 @@ func (m *UserMutation) Fields() []string { if m.status != nil { fields = append(fields, user.FieldStatus) } + if m.lastLoginAt != nil { + fields = append(fields, user.FieldLastLoginAt) + } if m.createdAt != nil { fields = append(fields, user.FieldCreatedAt) } @@ -16509,6 +16638,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.WorkstationPassword() case user.FieldStatus: return m.Status() + case user.FieldLastLoginAt: + return m.LastLoginAt() case user.FieldCreatedAt: return m.CreatedAt() case user.FieldUpdatedAt: @@ -16536,6 +16667,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldWorkstationPassword(ctx) case user.FieldStatus: return m.OldStatus(ctx) + case user.FieldLastLoginAt: + return m.OldLastLoginAt(ctx) case user.FieldCreatedAt: return m.OldCreatedAt(ctx) case user.FieldUpdatedAt: @@ -16598,6 +16731,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetStatus(v) return nil + case user.FieldLastLoginAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastLoginAt(v) + return nil case user.FieldCreatedAt: v, ok := value.(time.Time) if !ok { @@ -16623,6 +16763,9 @@ func (m *UserMutation) AddedFields() []string { if m.addroleId != nil { fields = append(fields, user.FieldRoleId) } + if m.addlastLoginAt != nil { + fields = append(fields, user.FieldLastLoginAt) + } return fields } @@ -16633,6 +16776,8 @@ func (m *UserMutation) AddedField(name string) (ent.Value, bool) { switch name { case user.FieldRoleId: return m.AddedRoleId() + case user.FieldLastLoginAt: + return m.AddedLastLoginAt() } return nil, false } @@ -16649,6 +16794,13 @@ func (m *UserMutation) AddField(name string, value ent.Value) error { } m.AddRoleId(v) return nil + case user.FieldLastLoginAt: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLastLoginAt(v) + return nil } return fmt.Errorf("unknown User numeric field %s", name) } @@ -16663,6 +16815,9 @@ func (m *UserMutation) ClearedFields() []string { if m.FieldCleared(user.FieldWorkstationPassword) { fields = append(fields, user.FieldWorkstationPassword) } + if m.FieldCleared(user.FieldLastLoginAt) { + fields = append(fields, user.FieldLastLoginAt) + } if m.FieldCleared(user.FieldUpdatedAt) { fields = append(fields, user.FieldUpdatedAt) } @@ -16686,6 +16841,9 @@ func (m *UserMutation) ClearField(name string) error { case user.FieldWorkstationPassword: m.ClearWorkstationPassword() return nil + case user.FieldLastLoginAt: + m.ClearLastLoginAt() + return nil case user.FieldUpdatedAt: m.ClearUpdatedAt() return nil @@ -16718,6 +16876,9 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldStatus: m.ResetStatus() return nil + case user.FieldLastLoginAt: + m.ResetLastLoginAt() + return nil case user.FieldCreatedAt: m.ResetCreatedAt() return nil @@ -17295,6 +17456,7 @@ type WorkOrderMutation struct { productTypeId *int addproductTypeId *int productCode *string + bomName *string productName *string quantity *int addquantity *int @@ -17548,6 +17710,42 @@ func (m *WorkOrderMutation) ResetProductCode() { m.productCode = nil } +// SetBomName sets the "bomName" field. +func (m *WorkOrderMutation) SetBomName(s string) { + m.bomName = &s +} + +// BomName returns the value of the "bomName" field in the mutation. +func (m *WorkOrderMutation) BomName() (r string, exists bool) { + v := m.bomName + if v == nil { + return + } + return *v, true +} + +// OldBomName returns the old "bomName" 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) OldBomName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldBomName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldBomName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldBomName: %w", err) + } + return oldValue.BomName, nil +} + +// ResetBomName resets all changes to the "bomName" field. +func (m *WorkOrderMutation) ResetBomName() { + m.bomName = nil +} + // SetProductName sets the "productName" field. func (m *WorkOrderMutation) SetProductName(s string) { m.productName = &s @@ -18139,7 +18337,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, 15) + fields := make([]string, 0, 16) if m.workOrderNo != nil { fields = append(fields, workorder.FieldWorkOrderNo) } @@ -18149,6 +18347,9 @@ func (m *WorkOrderMutation) Fields() []string { if m.productCode != nil { fields = append(fields, workorder.FieldProductCode) } + if m.bomName != nil { + fields = append(fields, workorder.FieldBomName) + } if m.productName != nil { fields = append(fields, workorder.FieldProductName) } @@ -18199,6 +18400,8 @@ func (m *WorkOrderMutation) Field(name string) (ent.Value, bool) { return m.ProductTypeId() case workorder.FieldProductCode: return m.ProductCode() + case workorder.FieldBomName: + return m.BomName() case workorder.FieldProductName: return m.ProductName() case workorder.FieldQuantity: @@ -18238,6 +18441,8 @@ func (m *WorkOrderMutation) OldField(ctx context.Context, name string) (ent.Valu return m.OldProductTypeId(ctx) case workorder.FieldProductCode: return m.OldProductCode(ctx) + case workorder.FieldBomName: + return m.OldBomName(ctx) case workorder.FieldProductName: return m.OldProductName(ctx) case workorder.FieldQuantity: @@ -18292,6 +18497,13 @@ func (m *WorkOrderMutation) SetField(name string, value ent.Value) error { } m.SetProductCode(v) return nil + case workorder.FieldBomName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetBomName(v) + return nil case workorder.FieldProductName: v, ok := value.(string) if !ok { @@ -18518,6 +18730,9 @@ func (m *WorkOrderMutation) ResetField(name string) error { case workorder.FieldProductCode: m.ResetProductCode() return nil + case workorder.FieldBomName: + m.ResetBomName() + return nil case workorder.FieldProductName: m.ResetProductName() return nil diff --git a/bj_power_mes/ent/runtime.go b/bj_power_mes/ent/runtime.go index c876a9a..8e2b67b 100644 --- a/bj_power_mes/ent/runtime.go +++ b/bj_power_mes/ent/runtime.go @@ -76,52 +76,58 @@ func init() { bomitem.DefaultProductCode = bomitemDescProductCode.Default.(string) // bomitem.ProductCodeValidator is a validator for the "productCode" field. It is called by the builders before save. bomitem.ProductCodeValidator = bomitemDescProductCode.Validators[0].(func(string) error) + // bomitemDescBomName is the schema descriptor for bomName field. + bomitemDescBomName := bomitemFields[2].Descriptor() + // bomitem.DefaultBomName holds the default value on creation for the bomName field. + bomitem.DefaultBomName = bomitemDescBomName.Default.(string) + // bomitem.BomNameValidator is a validator for the "bomName" field. It is called by the builders before save. + bomitem.BomNameValidator = bomitemDescBomName.Validators[0].(func(string) error) // bomitemDescMaterialCode is the schema descriptor for materialCode field. - bomitemDescMaterialCode := bomitemFields[2].Descriptor() + bomitemDescMaterialCode := bomitemFields[3].Descriptor() // bomitem.MaterialCodeValidator is a validator for the "materialCode" field. It is called by the builders before save. bomitem.MaterialCodeValidator = bomitemDescMaterialCode.Validators[0].(func(string) error) // bomitemDescMaterialName is the schema descriptor for materialName field. - bomitemDescMaterialName := bomitemFields[3].Descriptor() + bomitemDescMaterialName := bomitemFields[4].Descriptor() // bomitem.DefaultMaterialName holds the default value on creation for the materialName field. bomitem.DefaultMaterialName = bomitemDescMaterialName.Default.(string) // bomitem.MaterialNameValidator is a validator for the "materialName" field. It is called by the builders before save. bomitem.MaterialNameValidator = bomitemDescMaterialName.Validators[0].(func(string) error) // bomitemDescSpec is the schema descriptor for spec field. - bomitemDescSpec := bomitemFields[4].Descriptor() + bomitemDescSpec := bomitemFields[5].Descriptor() // bomitem.DefaultSpec holds the default value on creation for the spec field. bomitem.DefaultSpec = bomitemDescSpec.Default.(string) // bomitem.SpecValidator is a validator for the "spec" field. It is called by the builders before save. bomitem.SpecValidator = bomitemDescSpec.Validators[0].(func(string) error) // bomitemDescUnit is the schema descriptor for unit field. - bomitemDescUnit := bomitemFields[5].Descriptor() + bomitemDescUnit := bomitemFields[6].Descriptor() // bomitem.DefaultUnit holds the default value on creation for the unit field. bomitem.DefaultUnit = bomitemDescUnit.Default.(string) // bomitem.UnitValidator is a validator for the "unit" field. It is called by the builders before save. bomitem.UnitValidator = bomitemDescUnit.Validators[0].(func(string) error) // bomitemDescManageMode is the schema descriptor for manageMode field. - bomitemDescManageMode := bomitemFields[6].Descriptor() + bomitemDescManageMode := bomitemFields[7].Descriptor() // bomitem.DefaultManageMode holds the default value on creation for the manageMode field. bomitem.DefaultManageMode = bomitemDescManageMode.Default.(string) // bomitem.ManageModeValidator is a validator for the "manageMode" field. It is called by the builders before save. bomitem.ManageModeValidator = bomitemDescManageMode.Validators[0].(func(string) error) // bomitemDescProcessCode is the schema descriptor for processCode field. - bomitemDescProcessCode := bomitemFields[7].Descriptor() + bomitemDescProcessCode := bomitemFields[8].Descriptor() // bomitem.DefaultProcessCode holds the default value on creation for the processCode field. bomitem.DefaultProcessCode = bomitemDescProcessCode.Default.(int) // bomitemDescUnitQty is the schema descriptor for unitQty field. - bomitemDescUnitQty := bomitemFields[8].Descriptor() + bomitemDescUnitQty := bomitemFields[9].Descriptor() // bomitem.DefaultUnitQty holds the default value on creation for the unitQty field. bomitem.DefaultUnitQty = bomitemDescUnitQty.Default.(float64) // bomitemDescLossRate is the schema descriptor for lossRate field. - bomitemDescLossRate := bomitemFields[9].Descriptor() + bomitemDescLossRate := bomitemFields[10].Descriptor() // bomitem.DefaultLossRate holds the default value on creation for the lossRate field. bomitem.DefaultLossRate = bomitemDescLossRate.Default.(float64) // bomitemDescRequiredQty is the schema descriptor for requiredQty field. - bomitemDescRequiredQty := bomitemFields[10].Descriptor() + bomitemDescRequiredQty := bomitemFields[11].Descriptor() // bomitem.DefaultRequiredQty holds the default value on creation for the requiredQty field. bomitem.DefaultRequiredQty = bomitemDescRequiredQty.Default.(float64) // bomitemDescCreatedAt is the schema descriptor for createdAt field. - bomitemDescCreatedAt := bomitemFields[12].Descriptor() + bomitemDescCreatedAt := bomitemFields[13].Descriptor() // bomitem.DefaultCreatedAt holds the default value on creation for the createdAt field. bomitem.DefaultCreatedAt = bomitemDescCreatedAt.Default.(func() time.Time) // bomitemDescID is the schema descriptor for id field. @@ -889,11 +895,11 @@ func init() { // user.StatusValidator is a validator for the "status" field. It is called by the builders before save. user.StatusValidator = userDescStatus.Validators[0].(func(string) error) // userDescCreatedAt is the schema descriptor for createdAt field. - userDescCreatedAt := userFields[8].Descriptor() + userDescCreatedAt := userFields[9].Descriptor() // user.DefaultCreatedAt holds the default value on creation for the createdAt field. user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time) // userDescUpdatedAt is the schema descriptor for updatedAt field. - userDescUpdatedAt := userFields[9].Descriptor() + userDescUpdatedAt := userFields[10].Descriptor() // user.DefaultUpdatedAt holds the default value on creation for the updatedAt field. user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time) // user.UpdateDefaultUpdatedAt holds the default value on update for the updatedAt field. @@ -924,42 +930,48 @@ func init() { workorder.DefaultProductCode = workorderDescProductCode.Default.(string) // workorder.ProductCodeValidator is a validator for the "productCode" field. It is called by the builders before save. workorder.ProductCodeValidator = workorderDescProductCode.Validators[0].(func(string) error) + // workorderDescBomName is the schema descriptor for bomName field. + workorderDescBomName := workorderFields[4].Descriptor() + // workorder.DefaultBomName holds the default value on creation for the bomName field. + workorder.DefaultBomName = workorderDescBomName.Default.(string) + // workorder.BomNameValidator is a validator for the "bomName" field. It is called by the builders before save. + workorder.BomNameValidator = workorderDescBomName.Validators[0].(func(string) error) // workorderDescProductName is the schema descriptor for productName field. - workorderDescProductName := workorderFields[4].Descriptor() + workorderDescProductName := workorderFields[5].Descriptor() // workorder.DefaultProductName holds the default value on creation for the productName field. workorder.DefaultProductName = workorderDescProductName.Default.(string) // workorder.ProductNameValidator is a validator for the "productName" field. It is called by the builders before save. workorder.ProductNameValidator = workorderDescProductName.Validators[0].(func(string) error) // workorderDescQuantity is the schema descriptor for quantity field. - workorderDescQuantity := workorderFields[5].Descriptor() + workorderDescQuantity := workorderFields[6].Descriptor() // workorder.DefaultQuantity holds the default value on creation for the quantity field. workorder.DefaultQuantity = workorderDescQuantity.Default.(int) // workorderDescFinishedNum is the schema descriptor for finishedNum field. - workorderDescFinishedNum := workorderFields[6].Descriptor() + workorderDescFinishedNum := workorderFields[7].Descriptor() // workorder.DefaultFinishedNum holds the default value on creation for the finishedNum field. workorder.DefaultFinishedNum = workorderDescFinishedNum.Default.(int) // workorderDescFailNum is the schema descriptor for failNum field. - workorderDescFailNum := workorderFields[7].Descriptor() + workorderDescFailNum := workorderFields[8].Descriptor() // workorder.DefaultFailNum holds the default value on creation for the failNum field. workorder.DefaultFailNum = workorderDescFailNum.Default.(int) // workorderDescProcessSeq is the schema descriptor for processSeq field. - workorderDescProcessSeq := workorderFields[8].Descriptor() + workorderDescProcessSeq := workorderFields[9].Descriptor() // workorder.DefaultProcessSeq holds the default value on creation for the processSeq field. workorder.DefaultProcessSeq = workorderDescProcessSeq.Default.(string) // workorder.ProcessSeqValidator is a validator for the "processSeq" field. It is called by the builders before save. workorder.ProcessSeqValidator = workorderDescProcessSeq.Validators[0].(func(string) error) // workorderDescStatus is the schema descriptor for status field. - workorderDescStatus := workorderFields[9].Descriptor() + workorderDescStatus := workorderFields[10].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[14].Descriptor() + workorderDescCreatedAt := workorderFields[15].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[15].Descriptor() + workorderDescUpdatedAt := workorderFields[16].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/user.go b/bj_power_mes/ent/user.go index af5f942..53086c7 100644 --- a/bj_power_mes/ent/user.go +++ b/bj_power_mes/ent/user.go @@ -31,6 +31,8 @@ type User struct { WorkstationPassword string `json:"workstationPassword,omitempty"` // Status holds the value of the "status" field. Status string `json:"status,omitempty"` + // 最近登录时间(unix秒,后台登录更新;工位终端登录不计) + LastLoginAt *int64 `json:"lastLoginAt,omitempty"` // CreatedAt holds the value of the "createdAt" field. CreatedAt time.Time `json:"createdAt,omitempty"` // UpdatedAt holds the value of the "updatedAt" field. @@ -45,7 +47,7 @@ func (*User) scanValues(columns []string) ([]any, error) { switch columns[i] { case user.FieldCanLoginWorkstation: values[i] = new(sql.NullBool) - case user.FieldID, user.FieldRoleId: + case user.FieldID, user.FieldRoleId, user.FieldLastLoginAt: values[i] = new(sql.NullInt64) case user.FieldUsername, user.FieldPassword, user.FieldName, user.FieldWorkstationPassword, user.FieldStatus: values[i] = new(sql.NullString) @@ -114,6 +116,13 @@ func (_m *User) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Status = value.String } + case user.FieldLastLoginAt: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field lastLoginAt", values[i]) + } else if value.Valid { + _m.LastLoginAt = new(int64) + *_m.LastLoginAt = value.Int64 + } case user.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field createdAt", values[i]) @@ -184,6 +193,11 @@ func (_m *User) String() string { builder.WriteString("status=") builder.WriteString(_m.Status) builder.WriteString(", ") + if v := _m.LastLoginAt; v != nil { + builder.WriteString("lastLoginAt=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } + builder.WriteString(", ") builder.WriteString("createdAt=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") diff --git a/bj_power_mes/ent/user/user.go b/bj_power_mes/ent/user/user.go index fec9ab6..69baac5 100644 --- a/bj_power_mes/ent/user/user.go +++ b/bj_power_mes/ent/user/user.go @@ -27,6 +27,8 @@ const ( FieldWorkstationPassword = "workstation_password" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" + // FieldLastLoginAt holds the string denoting the lastloginat field in the database. + FieldLastLoginAt = "last_login_at" // FieldCreatedAt holds the string denoting the createdat field in the database. FieldCreatedAt = "created_at" // FieldUpdatedAt holds the string denoting the updatedat field in the database. @@ -45,6 +47,7 @@ var Columns = []string{ FieldCanLoginWorkstation, FieldWorkstationPassword, FieldStatus, + FieldLastLoginAt, FieldCreatedAt, FieldUpdatedAt, } @@ -129,6 +132,11 @@ func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } +// ByLastLoginAt orders the results by the lastLoginAt field. +func ByLastLoginAt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastLoginAt, 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/user/where.go b/bj_power_mes/ent/user/where.go index 42f67f1..a6ce3cb 100644 --- a/bj_power_mes/ent/user/where.go +++ b/bj_power_mes/ent/user/where.go @@ -89,6 +89,11 @@ func Status(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldStatus, v)) } +// LastLoginAt applies equality check predicate on the "lastLoginAt" field. It's identical to LastLoginAtEQ. +func LastLoginAt(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginAt, v)) +} + // CreatedAt applies equality check predicate on the "createdAt" field. It's identical to CreatedAtEQ. func CreatedAt(v time.Time) predicate.User { return predicate.User(sql.FieldEQ(FieldCreatedAt, v)) @@ -494,6 +499,56 @@ func StatusContainsFold(v string) predicate.User { return predicate.User(sql.FieldContainsFold(FieldStatus, v)) } +// LastLoginAtEQ applies the EQ predicate on the "lastLoginAt" field. +func LastLoginAtEQ(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginAt, v)) +} + +// LastLoginAtNEQ applies the NEQ predicate on the "lastLoginAt" field. +func LastLoginAtNEQ(v int64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLastLoginAt, v)) +} + +// LastLoginAtIn applies the In predicate on the "lastLoginAt" field. +func LastLoginAtIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldIn(FieldLastLoginAt, vs...)) +} + +// LastLoginAtNotIn applies the NotIn predicate on the "lastLoginAt" field. +func LastLoginAtNotIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLastLoginAt, vs...)) +} + +// LastLoginAtGT applies the GT predicate on the "lastLoginAt" field. +func LastLoginAtGT(v int64) predicate.User { + return predicate.User(sql.FieldGT(FieldLastLoginAt, v)) +} + +// LastLoginAtGTE applies the GTE predicate on the "lastLoginAt" field. +func LastLoginAtGTE(v int64) predicate.User { + return predicate.User(sql.FieldGTE(FieldLastLoginAt, v)) +} + +// LastLoginAtLT applies the LT predicate on the "lastLoginAt" field. +func LastLoginAtLT(v int64) predicate.User { + return predicate.User(sql.FieldLT(FieldLastLoginAt, v)) +} + +// LastLoginAtLTE applies the LTE predicate on the "lastLoginAt" field. +func LastLoginAtLTE(v int64) predicate.User { + return predicate.User(sql.FieldLTE(FieldLastLoginAt, v)) +} + +// LastLoginAtIsNil applies the IsNil predicate on the "lastLoginAt" field. +func LastLoginAtIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldLastLoginAt)) +} + +// LastLoginAtNotNil applies the NotNil predicate on the "lastLoginAt" field. +func LastLoginAtNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldLastLoginAt)) +} + // CreatedAtEQ applies the EQ predicate on the "createdAt" field. func CreatedAtEQ(v time.Time) predicate.User { return predicate.User(sql.FieldEQ(FieldCreatedAt, v)) diff --git a/bj_power_mes/ent/user_create.go b/bj_power_mes/ent/user_create.go index 38d7672..6a9b4a7 100644 --- a/bj_power_mes/ent/user_create.go +++ b/bj_power_mes/ent/user_create.go @@ -102,6 +102,20 @@ func (_c *UserCreate) SetNillableStatus(v *string) *UserCreate { return _c } +// SetLastLoginAt sets the "lastLoginAt" field. +func (_c *UserCreate) SetLastLoginAt(v int64) *UserCreate { + _c.mutation.SetLastLoginAt(v) + return _c +} + +// SetNillableLastLoginAt sets the "lastLoginAt" field if the given value is not nil. +func (_c *UserCreate) SetNillableLastLoginAt(v *int64) *UserCreate { + if v != nil { + _c.SetLastLoginAt(*v) + } + return _c +} + // SetCreatedAt sets the "createdAt" field. func (_c *UserCreate) SetCreatedAt(v time.Time) *UserCreate { _c.mutation.SetCreatedAt(v) @@ -303,6 +317,10 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldStatus, field.TypeString, value) _node.Status = value } + if value, ok := _c.mutation.LastLoginAt(); ok { + _spec.SetField(user.FieldLastLoginAt, field.TypeInt64, value) + _node.LastLoginAt = &value + } if value, ok := _c.mutation.CreatedAt(); ok { _spec.SetField(user.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value diff --git a/bj_power_mes/ent/user_update.go b/bj_power_mes/ent/user_update.go index a305fd7..fb37dc6 100644 --- a/bj_power_mes/ent/user_update.go +++ b/bj_power_mes/ent/user_update.go @@ -146,6 +146,33 @@ func (_u *UserUpdate) SetNillableStatus(v *string) *UserUpdate { return _u } +// SetLastLoginAt sets the "lastLoginAt" field. +func (_u *UserUpdate) SetLastLoginAt(v int64) *UserUpdate { + _u.mutation.ResetLastLoginAt() + _u.mutation.SetLastLoginAt(v) + return _u +} + +// SetNillableLastLoginAt sets the "lastLoginAt" field if the given value is not nil. +func (_u *UserUpdate) SetNillableLastLoginAt(v *int64) *UserUpdate { + if v != nil { + _u.SetLastLoginAt(*v) + } + return _u +} + +// AddLastLoginAt adds value to the "lastLoginAt" field. +func (_u *UserUpdate) AddLastLoginAt(v int64) *UserUpdate { + _u.mutation.AddLastLoginAt(v) + return _u +} + +// ClearLastLoginAt clears the value of the "lastLoginAt" field. +func (_u *UserUpdate) ClearLastLoginAt() *UserUpdate { + _u.mutation.ClearLastLoginAt() + return _u +} + // SetUpdatedAt sets the "updatedAt" field. func (_u *UserUpdate) SetUpdatedAt(v time.Time) *UserUpdate { _u.mutation.SetUpdatedAt(v) @@ -277,6 +304,15 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Status(); ok { _spec.SetField(user.FieldStatus, field.TypeString, value) } + if value, ok := _u.mutation.LastLoginAt(); ok { + _spec.SetField(user.FieldLastLoginAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedLastLoginAt(); ok { + _spec.AddField(user.FieldLastLoginAt, field.TypeInt64, value) + } + if _u.mutation.LastLoginAtCleared() { + _spec.ClearField(user.FieldLastLoginAt, field.TypeInt64) + } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) } @@ -422,6 +458,33 @@ func (_u *UserUpdateOne) SetNillableStatus(v *string) *UserUpdateOne { return _u } +// SetLastLoginAt sets the "lastLoginAt" field. +func (_u *UserUpdateOne) SetLastLoginAt(v int64) *UserUpdateOne { + _u.mutation.ResetLastLoginAt() + _u.mutation.SetLastLoginAt(v) + return _u +} + +// SetNillableLastLoginAt sets the "lastLoginAt" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableLastLoginAt(v *int64) *UserUpdateOne { + if v != nil { + _u.SetLastLoginAt(*v) + } + return _u +} + +// AddLastLoginAt adds value to the "lastLoginAt" field. +func (_u *UserUpdateOne) AddLastLoginAt(v int64) *UserUpdateOne { + _u.mutation.AddLastLoginAt(v) + return _u +} + +// ClearLastLoginAt clears the value of the "lastLoginAt" field. +func (_u *UserUpdateOne) ClearLastLoginAt() *UserUpdateOne { + _u.mutation.ClearLastLoginAt() + return _u +} + // SetUpdatedAt sets the "updatedAt" field. func (_u *UserUpdateOne) SetUpdatedAt(v time.Time) *UserUpdateOne { _u.mutation.SetUpdatedAt(v) @@ -583,6 +646,15 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if value, ok := _u.mutation.Status(); ok { _spec.SetField(user.FieldStatus, field.TypeString, value) } + if value, ok := _u.mutation.LastLoginAt(); ok { + _spec.SetField(user.FieldLastLoginAt, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedLastLoginAt(); ok { + _spec.AddField(user.FieldLastLoginAt, field.TypeInt64, value) + } + if _u.mutation.LastLoginAtCleared() { + _spec.ClearField(user.FieldLastLoginAt, field.TypeInt64) + } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(user.FieldUpdatedAt, field.TypeTime, value) } diff --git a/bj_power_mes/ent/workorder.go b/bj_power_mes/ent/workorder.go index dec74b7..a6f71b0 100644 --- a/bj_power_mes/ent/workorder.go +++ b/bj_power_mes/ent/workorder.go @@ -24,6 +24,8 @@ type WorkOrder struct { ProductTypeId int `json:"productTypeId,omitempty"` // 产品编码 ProductCode string `json:"productCode,omitempty"` + // 建单时选定的BOM名称(该型号下多份BOM之一,备料按此计算) + BomName string `json:"bomName,omitempty"` // ProductName holds the value of the "productName" field. ProductName string `json:"productName,omitempty"` // 工件数量 @@ -60,7 +62,7 @@ func (*WorkOrder) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case workorder.FieldID, workorder.FieldProductTypeId, workorder.FieldQuantity, workorder.FieldFinishedNum, workorder.FieldFailNum: values[i] = new(sql.NullInt64) - case workorder.FieldWorkOrderNo, workorder.FieldProductCode, workorder.FieldProductName, workorder.FieldProcessSeq, workorder.FieldStatus: + case workorder.FieldWorkOrderNo, workorder.FieldProductCode, workorder.FieldBomName, workorder.FieldProductName, workorder.FieldProcessSeq, workorder.FieldStatus: values[i] = new(sql.NullString) case workorder.FieldPlanStart, workorder.FieldPlanEnd, workorder.FieldCompletedAt, workorder.FieldCreatedAt, workorder.FieldUpdatedAt: values[i] = new(sql.NullTime) @@ -103,6 +105,12 @@ func (_m *WorkOrder) assignValues(columns []string, values []any) error { } else if value.Valid { _m.ProductCode = value.String } + case workorder.FieldBomName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field bomName", values[i]) + } else if value.Valid { + _m.BomName = value.String + } case workorder.FieldProductName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field productName", values[i]) @@ -226,6 +234,9 @@ func (_m *WorkOrder) String() string { builder.WriteString("productCode=") builder.WriteString(_m.ProductCode) builder.WriteString(", ") + builder.WriteString("bomName=") + builder.WriteString(_m.BomName) + builder.WriteString(", ") builder.WriteString("productName=") builder.WriteString(_m.ProductName) builder.WriteString(", ") diff --git a/bj_power_mes/ent/workorder/where.go b/bj_power_mes/ent/workorder/where.go index e171b94..c65efcf 100644 --- a/bj_power_mes/ent/workorder/where.go +++ b/bj_power_mes/ent/workorder/where.go @@ -69,6 +69,11 @@ func ProductCode(v string) predicate.WorkOrder { return predicate.WorkOrder(sql.FieldEQ(FieldProductCode, v)) } +// BomName applies equality check predicate on the "bomName" field. It's identical to BomNameEQ. +func BomName(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldEQ(FieldBomName, v)) +} + // ProductName applies equality check predicate on the "productName" field. It's identical to ProductNameEQ. func ProductName(v string) predicate.WorkOrder { return predicate.WorkOrder(sql.FieldEQ(FieldProductName, v)) @@ -294,6 +299,71 @@ func ProductCodeContainsFold(v string) predicate.WorkOrder { return predicate.WorkOrder(sql.FieldContainsFold(FieldProductCode, v)) } +// BomNameEQ applies the EQ predicate on the "bomName" field. +func BomNameEQ(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldEQ(FieldBomName, v)) +} + +// BomNameNEQ applies the NEQ predicate on the "bomName" field. +func BomNameNEQ(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldNEQ(FieldBomName, v)) +} + +// BomNameIn applies the In predicate on the "bomName" field. +func BomNameIn(vs ...string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldIn(FieldBomName, vs...)) +} + +// BomNameNotIn applies the NotIn predicate on the "bomName" field. +func BomNameNotIn(vs ...string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldNotIn(FieldBomName, vs...)) +} + +// BomNameGT applies the GT predicate on the "bomName" field. +func BomNameGT(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldGT(FieldBomName, v)) +} + +// BomNameGTE applies the GTE predicate on the "bomName" field. +func BomNameGTE(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldGTE(FieldBomName, v)) +} + +// BomNameLT applies the LT predicate on the "bomName" field. +func BomNameLT(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldLT(FieldBomName, v)) +} + +// BomNameLTE applies the LTE predicate on the "bomName" field. +func BomNameLTE(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldLTE(FieldBomName, v)) +} + +// BomNameContains applies the Contains predicate on the "bomName" field. +func BomNameContains(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldContains(FieldBomName, v)) +} + +// BomNameHasPrefix applies the HasPrefix predicate on the "bomName" field. +func BomNameHasPrefix(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldHasPrefix(FieldBomName, v)) +} + +// BomNameHasSuffix applies the HasSuffix predicate on the "bomName" field. +func BomNameHasSuffix(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldHasSuffix(FieldBomName, v)) +} + +// BomNameEqualFold applies the EqualFold predicate on the "bomName" field. +func BomNameEqualFold(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldEqualFold(FieldBomName, v)) +} + +// BomNameContainsFold applies the ContainsFold predicate on the "bomName" field. +func BomNameContainsFold(v string) predicate.WorkOrder { + return predicate.WorkOrder(sql.FieldContainsFold(FieldBomName, v)) +} + // ProductNameEQ applies the EQ predicate on the "productName" field. func ProductNameEQ(v string) predicate.WorkOrder { return predicate.WorkOrder(sql.FieldEQ(FieldProductName, v)) diff --git a/bj_power_mes/ent/workorder/workorder.go b/bj_power_mes/ent/workorder/workorder.go index 8de8eb3..c59c76e 100644 --- a/bj_power_mes/ent/workorder/workorder.go +++ b/bj_power_mes/ent/workorder/workorder.go @@ -19,6 +19,8 @@ const ( FieldProductTypeId = "product_type_id" // FieldProductCode holds the string denoting the productcode field in the database. FieldProductCode = "product_code" + // FieldBomName holds the string denoting the bomname field in the database. + FieldBomName = "bom_name" // FieldProductName holds the string denoting the productname field in the database. FieldProductName = "product_name" // FieldQuantity holds the string denoting the quantity field in the database. @@ -53,6 +55,7 @@ var Columns = []string{ FieldWorkOrderNo, FieldProductTypeId, FieldProductCode, + FieldBomName, FieldProductName, FieldQuantity, FieldFinishedNum, @@ -84,6 +87,10 @@ var ( DefaultProductCode string // ProductCodeValidator is a validator for the "productCode" field. It is called by the builders before save. ProductCodeValidator func(string) error + // DefaultBomName holds the default value on creation for the "bomName" field. + DefaultBomName string + // BomNameValidator is a validator for the "bomName" field. It is called by the builders before save. + BomNameValidator 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. @@ -135,6 +142,11 @@ func ByProductCode(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldProductCode, opts...).ToFunc() } +// ByBomName orders the results by the bomName field. +func ByBomName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldBomName, opts...).ToFunc() +} + // ByProductName orders the results by the productName field. func ByProductName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldProductName, opts...).ToFunc() diff --git a/bj_power_mes/ent/workorder_create.go b/bj_power_mes/ent/workorder_create.go index e170352..b6b22bb 100644 --- a/bj_power_mes/ent/workorder_create.go +++ b/bj_power_mes/ent/workorder_create.go @@ -46,6 +46,20 @@ func (_c *WorkOrderCreate) SetNillableProductCode(v *string) *WorkOrderCreate { return _c } +// SetBomName sets the "bomName" field. +func (_c *WorkOrderCreate) SetBomName(v string) *WorkOrderCreate { + _c.mutation.SetBomName(v) + return _c +} + +// SetNillableBomName sets the "bomName" field if the given value is not nil. +func (_c *WorkOrderCreate) SetNillableBomName(v *string) *WorkOrderCreate { + if v != nil { + _c.SetBomName(*v) + } + return _c +} + // SetProductName sets the "productName" field. func (_c *WorkOrderCreate) SetProductName(v string) *WorkOrderCreate { _c.mutation.SetProductName(v) @@ -251,6 +265,10 @@ func (_c *WorkOrderCreate) defaults() { v := workorder.DefaultProductCode _c.mutation.SetProductCode(v) } + if _, ok := _c.mutation.BomName(); !ok { + v := workorder.DefaultBomName + _c.mutation.SetBomName(v) + } if _, ok := _c.mutation.ProductName(); !ok { v := workorder.DefaultProductName _c.mutation.SetProductName(v) @@ -306,6 +324,14 @@ func (_c *WorkOrderCreate) check() error { return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.productCode": %w`, err)} } } + if _, ok := _c.mutation.BomName(); !ok { + return &ValidationError{Name: "bomName", err: errors.New(`ent: missing required field "WorkOrder.bomName"`)} + } + if v, ok := _c.mutation.BomName(); ok { + if err := workorder.BomNameValidator(v); err != nil { + return &ValidationError{Name: "bomName", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.bomName": %w`, err)} + } + } if _, ok := _c.mutation.ProductName(); !ok { return &ValidationError{Name: "productName", err: errors.New(`ent: missing required field "WorkOrder.productName"`)} } @@ -391,6 +417,10 @@ func (_c *WorkOrderCreate) createSpec() (*WorkOrder, *sqlgraph.CreateSpec) { _spec.SetField(workorder.FieldProductCode, field.TypeString, value) _node.ProductCode = value } + if value, ok := _c.mutation.BomName(); ok { + _spec.SetField(workorder.FieldBomName, field.TypeString, value) + _node.BomName = value + } if value, ok := _c.mutation.ProductName(); ok { _spec.SetField(workorder.FieldProductName, field.TypeString, value) _node.ProductName = value diff --git a/bj_power_mes/ent/workorder_update.go b/bj_power_mes/ent/workorder_update.go index ee15a89..b2d1d89 100644 --- a/bj_power_mes/ent/workorder_update.go +++ b/bj_power_mes/ent/workorder_update.go @@ -78,6 +78,20 @@ func (_u *WorkOrderUpdate) SetNillableProductCode(v *string) *WorkOrderUpdate { return _u } +// SetBomName sets the "bomName" field. +func (_u *WorkOrderUpdate) SetBomName(v string) *WorkOrderUpdate { + _u.mutation.SetBomName(v) + return _u +} + +// SetNillableBomName sets the "bomName" field if the given value is not nil. +func (_u *WorkOrderUpdate) SetNillableBomName(v *string) *WorkOrderUpdate { + if v != nil { + _u.SetBomName(*v) + } + return _u +} + // SetProductName sets the "productName" field. func (_u *WorkOrderUpdate) SetProductName(v string) *WorkOrderUpdate { _u.mutation.SetProductName(v) @@ -320,6 +334,11 @@ func (_u *WorkOrderUpdate) check() error { return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.productCode": %w`, err)} } } + if v, ok := _u.mutation.BomName(); ok { + if err := workorder.BomNameValidator(v); err != nil { + return &ValidationError{Name: "bomName", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.bomName": %w`, err)} + } + } if v, ok := _u.mutation.ProductName(); ok { if err := workorder.ProductNameValidator(v); err != nil { return &ValidationError{Name: "productName", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.productName": %w`, err)} @@ -368,6 +387,9 @@ func (_u *WorkOrderUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.ProductCode(); ok { _spec.SetField(workorder.FieldProductCode, field.TypeString, value) } + if value, ok := _u.mutation.BomName(); ok { + _spec.SetField(workorder.FieldBomName, field.TypeString, value) + } if value, ok := _u.mutation.ProductName(); ok { _spec.SetField(workorder.FieldProductName, field.TypeString, value) } @@ -496,6 +518,20 @@ func (_u *WorkOrderUpdateOne) SetNillableProductCode(v *string) *WorkOrderUpdate return _u } +// SetBomName sets the "bomName" field. +func (_u *WorkOrderUpdateOne) SetBomName(v string) *WorkOrderUpdateOne { + _u.mutation.SetBomName(v) + return _u +} + +// SetNillableBomName sets the "bomName" field if the given value is not nil. +func (_u *WorkOrderUpdateOne) SetNillableBomName(v *string) *WorkOrderUpdateOne { + if v != nil { + _u.SetBomName(*v) + } + return _u +} + // SetProductName sets the "productName" field. func (_u *WorkOrderUpdateOne) SetProductName(v string) *WorkOrderUpdateOne { _u.mutation.SetProductName(v) @@ -751,6 +787,11 @@ func (_u *WorkOrderUpdateOne) check() error { return &ValidationError{Name: "productCode", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.productCode": %w`, err)} } } + if v, ok := _u.mutation.BomName(); ok { + if err := workorder.BomNameValidator(v); err != nil { + return &ValidationError{Name: "bomName", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.bomName": %w`, err)} + } + } if v, ok := _u.mutation.ProductName(); ok { if err := workorder.ProductNameValidator(v); err != nil { return &ValidationError{Name: "productName", err: fmt.Errorf(`ent: validator failed for field "WorkOrder.productName": %w`, err)} @@ -816,6 +857,9 @@ func (_u *WorkOrderUpdateOne) sqlSave(ctx context.Context) (_node *WorkOrder, er if value, ok := _u.mutation.ProductCode(); ok { _spec.SetField(workorder.FieldProductCode, field.TypeString, value) } + if value, ok := _u.mutation.BomName(); ok { + _spec.SetField(workorder.FieldBomName, field.TypeString, value) + } if value, ok := _u.mutation.ProductName(); ok { _spec.SetField(workorder.FieldProductName, field.TypeString, value) } diff --git a/bj_power_mes/frontend/src/components/ProcessSeqPicker.vue b/bj_power_mes/frontend/src/components/ProcessSeqPicker.vue index 2c5993b..ec368e7 100644 --- a/bj_power_mes/frontend/src/components/ProcessSeqPicker.vue +++ b/bj_power_mes/frontend/src/components/ProcessSeqPicker.vue @@ -6,7 +6,7 @@ {{ summary }} - 工位{{ i }} + 工位{{ i }} @@ -15,7 +15,8 @@ import { computed } from 'vue' const props = defineProps({ - modelValue: { type: String, default: '' } + modelValue: { type: String, default: '' }, + disabledCodes: { type: Array, default: () => [] } // 已完成工位号禁选(如 ≤当前工位) }) const emit = defineEmits(['update:modelValue']) diff --git a/bj_power_mes/frontend/src/help.js b/bj_power_mes/frontend/src/help.js index 6773cf2..ddbe94f 100644 --- a/bj_power_mes/frontend/src/help.js +++ b/bj_power_mes/frontend/src/help.js @@ -3,16 +3,16 @@ // 说明:这里的"数据来源"特指该字段的数据由谁产生、从哪个系统/页面来,帮助跑通真实流程。 export const helpProductType = { - title: '产品类型(档案维护)', + title: '产品型号(档案维护)', overview: - '产品类型 = 企业要生产哪些产品的分类档案,是整条产线的源头基础数据。\n\n主数据链条:产品类型 → 工单(选产品类型) → 物料清单(给该产品编码配料) → 日排产 → 备料单 → 库房出库 → 产线生产。\n\n关系说明(几对几):\n· 产品类型 ↔ 工单:1 对 N。一个产品类型可以建多个工单(同一型号今天做一批、明天做一批,工单号不同、产品编码相同)。\n· 产品类型 ↔ 物料清单:按产品编码 1 对 1。同型号产品共用一份 BOM。\n· 产品类型 ↔ 备料单:间接。备料单由「日排产 × 该产品 BOM」算出,与产品类型无直接约束。\n· 强约束:工单/物料清单都挂在产品编码下,产品类型编码变了,下游关联会断,建议建好后不要改。\n· 与 WMS 的关系:两套系统解耦。本页(MES)维护产品与 BOM;WMS(库房)维护物料档案与库存,靠「物料编码」对齐;成品编码由人员手动录入 WMS 实现两系统对齐。', + '产品型号 = 企业要生产哪些产品的分类档案,是整条产线的源头基础数据。\n\n主数据链条:产品型号 → 工单(选产品型号+BOM) → 物料清单(给该产品编码配料) → 日排产 → 备料单 → 库房出库 → 产线生产 → 完工成品自动回流 WMS 入库。\n\n关系说明(几对几):\n· 产品型号 ↔ 工单:1 对 N。一个产品型号可以建多个工单(同一型号今天做一批、明天做一批,工单号不同、产品编码相同)。\n· 产品型号 ↔ 物料清单:1 对多(选用制)。同一型号可并存多份 BOM(不同厂家供货/含半成品结构),用「BOM 名称」区分,工单建单时选定一份,备料/装机都按工单锁定的那份算。\n· 产品型号 ↔ 备料单:间接。备料单由「日排产 × 工单锁定的 BOM」算出,与产品型号无直接约束。\n· 强约束:工单/物料清单都挂在产品编码下,产品型号编码变了,下游关联会断,建议建好后不要改。\n· 与 WMS 的关系:两套系统解耦。产品/物料编码主数据以 WMS 为单一来源,MES 实时拉取(WMS 不可达时允许手填、仅提示不强校验);成品完工后由系统自动生成 SN 回流 WMS 入库,无需人工对账。', fields: [ - { name: '名称', source: '手工填写。用户自定义,无上游来源。', purpose: '产品类型的中文名,用于识别与下拉展示', fill: '如:智能电表、断路器、配电柜' }, + { name: '名称', source: '手工填写。用户自定义,无上游来源。', purpose: '产品型号的中文名,用于识别与下拉展示', fill: '如:智能电表、断路器、配电柜' }, { name: '编码', source: '系统自动生成 + 可手动修改。新建时会自动带出(格式 PROD-YYYYMMDD-序号),你可直接使用或改为自定义编码;编辑时保留已存值。一个产品编码可对应多个工单(同一型号今天做一批、明天做一批,工单号不同,产品编码相同)。', purpose: '产品唯一编码。它是 MES 内部识别该产品的标识,决定该产品的物料清单(BOM)内容,也是工单、备料、拧紧、追溯的挂靠键。', - fill: '建议用有意义的编码,如 METER-01。要点:①本编码与 WMS 是两套系统、互相解耦,MES 这边独立维护,WMS 那边各自单独录入;②成品入库时,由操作人员把本编码**手动录入 WMS**,两系统靠人工对齐;③如产品编码就是"产品类型",则直接沿用该类型编码即可;④建好后不要随意改,否则下游工单/追溯的关联会断。' + fill: '建议用有意义的编码,如 METER-01。要点:①编码主数据以 WMS(库房) 为单一来源,本系统实时从 WMS 拉取物料/产品档案;WMS 不可达时允许手填、仅提示不强校验;②成品完工后系统自动生成 SN 并回流 WMS 入库,无需人工对账;③如产品编码就是"产品型号",则直接沿用该类型编码即可;④建好后不要随意改,否则下游工单/追溯的关联会断。' }, { name: '类别', source: '手工填写。可选,无上游来源。', purpose: '产品所属大类,便于分类统计', fill: '如:计量表 / 开关柜;可空' }, { name: '启用', source: '开关选择。默认开启。', purpose: '启用后才允许在新建工单/备料的下拉里被选到', fill: '默认开启;暂时停产的可关闭(不删除,保留档案)' }, @@ -23,15 +23,16 @@ export const helpProductType = { export const helpWorkOrder = { title: '工单管理(新建 / 编辑 / 删除工单)', overview: - '工单 = 一个"合同/生产批次"的唯一载体,是生产执行和仓库出库挂靠的核心对象。\n\n全流程:先有产品类型 → 建工单(选产品类型、定数量、勾选工位组合) → 进"物料清单"给该产品配料 → 到"日排产"排哪天产多少 → 仓库按排产备料出库 → 产线装配/拧紧/报工 → 完工。\n工单号会贯穿 备料单、拧紧查询、手动报工、工件追溯、操作日志 全链路。\n\n查询:支持按 工单号 / 产品编码 / 产品名称(模糊) / 状态 组合筛选。\n删除:仅「已创建 / 待排产 / 已发布」且无排产、备料、生产数据的工单可删除(操作列「删除」),生产中或已完成的工单不可删除。', + '工单 = 一个"合同/生产批次"的唯一载体,是生产执行和仓库出库挂靠的核心对象。\n\n全流程:先有产品型号 → 建工单(选产品型号、选定 BOM、定数量、勾选工位组合) → 进"物料清单"给该产品配料 → 到"日排产"排哪天产多少 → 仓库按排产备料出库 → 产线装配/拧紧/报工 → 完工(成品 SN 系统自动生成,并自动回流 WMS 入库为"成品"品类)。\n工单号会贯穿 备料单、拧紧查询、手动报工、工件追溯、操作日志 全链路。\n\n查询:支持按 工单号 / 产品编码 / 产品名称(模糊) / 状态 组合筛选;列表有 BOM 列显示各工单选用的 BOM 名称。\n删除:仅「已创建 / 待排产 / 已发布」且无排产、备料、生产数据的工单可删除(操作列「删除」),生产中或已完成的工单不可删除。', sections: [ { title: '工单基本信息', fields: [ { name: '工单号', source: '系统自动生成(WO+时间戳),可手工改。新建时自动带出。', purpose: '唯一标识一个工单,备料/出库/报工/追溯都挂在此号下', fill: '一般不用改;如改动须保证唯一' }, - { name: '产品类型', source: '下拉选择。数据来自"产品类型"页面已启用的记录。', purpose: '说明这批生产的是什么产品,并决定物料清单内容', fill: '先到"产品类型"页面建好记录再选择' }, - { name: '产品编码', source: '手工填写。通常与所选产品类型的编码一致。', purpose: '产品唯一编码,用于展示与追溯', fill: '如 METER-01,与产品类型编码对齐' }, - { name: '产品名称', source: '手工填写。通常与产品类型名称一致。', purpose: '产品中文名,用于展示', fill: '如 智能电表' }, + { name: '产品型号', source: '下拉选择。数据来自"产品型号"页面已启用的记录。', purpose: '说明这批生产的是什么产品,并决定物料清单内容', fill: '先到"产品型号"页面建好记录再选择' }, + { name: 'BOM 名称', source: '下拉选择。按所选产品编码实时拉取该型号下并存的 BOM(显示名称+料数),可输入新名创建。', purpose: '本工单选用哪一份 BOM;后续备料算料、装机绑定校验都锁定这一份,不同厂家料单互不串', fill: '一般选「默认」或对应厂家的料单名;不选则用「默认」' }, + { name: '产品编码', source: '手工填写。通常与所选产品型号的编码一致。', purpose: '产品唯一编码,用于展示与追溯', fill: '如 METER-01,与产品型号编码对齐' }, + { name: '产品名称', source: '手工填写。通常与产品型号名称一致。', purpose: '产品中文名,用于展示', fill: '如 智能电表' }, { name: '数量', source: '手工填写整数。', purpose: '本工单生产总数量(合同台数),决定需求量与排产上限', fill: '整数 ≥1,如 100' }, { name: '工位组合', source: '勾选 12 个工位(工位1~工位12)。', purpose: '本工单要经过的工位集合,PLC 按此组合下发控制产线', fill: '勾选要经过的工位即可,系统自动按 1→12 顺序执行(传送带不回走);半成品再上线可只勾漏做的工位' }, { name: '状态', source: '新建时选"已创建",后续由流程推进。', purpose: '工单生命周期:创建→发布→生产→完成', fill: '新建时选"已创建";也可在列表操作列点「状态」快捷流转(发布/开工/完工)' } @@ -64,9 +65,10 @@ export const helpDailyPlan = { export const helpBom = { title: '物料清单(产品 BOM)', overview: - '物料清单 = 生产 1 台该产品需要哪些物料、各用多少。\n按产品编码维护:同型号产品今天做一批、明天做一批,工单号不同、产品编码相同,共用这一份 BOM。\n仓库(库房)按工单取其产品的 BOM 计算备料/出库需求量,并强约束累计出库 ≤ 需求总量。\n\n与 WMS 的关系:本页(MES)只维护「产品由哪几种料、各用几个」;每种物料叫什么、规格、是精密件(SN)还是结构件(批次)、库存有多少,统一在 WMS(库房)的「物料档案」里维护,两套系统互相解耦、通过物料编码对齐。\n\n编码对应规则:本页的「物料编码」必须与 WMS 物料档案里的「编码」完全一致;「管理方式」也要对应(精密件=SN 逐件,结构件=批次)。编码对不上,WMS 将无法为对应工单备料/出库。\n\n数据链路:先建「产品类型」→ 到本页选产品编码,为它逐条添加物料 → 之后仓库才能为对应工单领料。', + '物料清单 = 生产 1 台该产品需要哪些物料、各用多少。\n按「产品编码 + BOM 名称」维护:同一产品编码可并存多份 BOM(选用制)——不同厂家供货、含半成品的结构差异,都用不同的 BOM 名称区分(缺省叫「默认」,不用 V1/V2 版本号)。\n工单建单时选定其中一份,之后该工单的备料算料、装机绑定校验都锁定这份 BOM,不同厂家的料单互不串。\n\n与 WMS 的关系:本页(MES)只维护「产品由哪几种料、各用几个」;每种物料叫什么、规格、是精密件(SN)还是结构件(批次)、库存有多少,统一在 WMS(库房)的「物料档案」里维护,两套系统互相解耦、通过物料编码对齐。\n\n编码对应规则:本页的「物料编码」必须与 WMS 物料档案里的「编码」完全一致;「管理方式」也要对应(精密件=SN 逐件,结构件=批次)。编码对不上,WMS 将无法为对应工单备料/出库。\n\n保护规则:某份 BOM 一旦被工单选用过,就不允许再从中移除物料(防止历史工单追溯断链);新建/改名的 BOM 名称在本页「BOM 名称」下拉直接输入即可创建。\n\n数据链路:先建「产品型号」→ 到本页选产品编码 + 命名 BOM,逐条添加物料 → 建工单时选定 BOM → 仓库才能为对应工单领料。', fields: [ - { name: '产品编码', source: '下拉选择。来自「产品类型」里建的编码。', purpose: '要为哪个产品配置物料清单', fill: '在查询区或「添加物料」弹窗里选择产品编码' }, + { name: 'BOM 名称', source: '下拉选择/输入(可搜索,输入新名即创建)。缺省「默认」。', purpose: '同一产品编码下多份 BOM 的区分名,工单建单时按此选定', fill: '如「默认」「A厂料单」「含半成品」;同一型号下名称唯一' }, + { name: '产品编码', source: '下拉选择。来自「产品型号」里建的编码。', purpose: '要为哪个产品配置物料清单', fill: '在查询区或「添加物料」弹窗里选择产品编码' }, { name: '物料编码', source: '手工填写。必须与 WMS(库房) 物料档案的编码一致。', purpose: '该物料在库房的全库唯一编码,两系统靠它关联', fill: '如 螺丝=GJ-LUOSI-M16;编码对不上 WMS 将无法备料' }, { name: '物料名称', source: '手工填写。', purpose: '物料中文名,便于识别', fill: '如 十字螺丝、主控芯片' }, { name: '规格', source: '手工填写。', purpose: '物料规格型号', fill: '如 M16×80 / SMT-48脚' }, @@ -101,39 +103,42 @@ export const helpMaterial = { } export const helpPlc = { - title: '工位组合下发(业务说明)', + title: '工位组合下发(下发录入 / 下发记录)', overview: - '这个菜单做什么用:把某个工单/工件的「工位组合」写入西门子 S7-1214 PLC,产线传送带据此只停靠勾选的工位,其余工位不加工。\n\n什么时候用:一个工件进线/上线时,需要告诉 PLC「这件货要走哪几个工位」,就在这里下发。\n\n为什么单独一个菜单:产线偶尔需要人工干预——比如本该走 3 号工位却做成了半成品,人工在此改成只补第 2 工位重上线,完成闭环。一切交给人工自行判断。\n\n核心约束:系统遵循「上一条未收到完成信号,不下发下一条」,确保产线不串序。\n\n数据链路:工单(含工位组合) → 本页下发到 S7-1214 → PLC 驱动传送带/工位 → 收到完成信号再下发下一条。', + '这个菜单做什么用:把某工单/工件的「工位组合」写入西门子 S7-1214 PLC,产线传送带据此只停靠勾选的工位,其余工位不加工。\n\n页面分两个页签:「下发录入」(默认打开)、「下发记录」(点击才加载,可按工单号/状态筛选)。\n\n操作流程:选工单号 → 下拉选出该工单已上线未完工的工件 SN(也可扫码/手输) → 系统按工件实际进度自动带出「当前工位」(只读) → 工位组合中 ≤ 当前工位的编号视为已完成,自动剔除且禁选 → 勾选剩余要走的工位 → 下发。\n\n为什么单独一个菜单:产线偶尔需要人工干预——比如本该走 3 号工位却做成了半成品,人工在此只勾剩余工位重上线,完成闭环。\n\n核心约束:系统遵循「上一条未收到完成信号,不下发下一条」,确保产线不串序。\n\n数据链路:工单(含工位组合) → 本页下发到 S7-1214 → PLC 驱动传送带/工位 → 收到完成信号再下发下一条。', fields: [ - { name: '工单号', source: '下拉选择/输入。来自工单。', purpose: '当前生产的工单,追溯依据', fill: '选择或输入工单号' }, - { name: '工件SN', source: '扫码枪扫描。来自工件条码。', purpose: '当前流经的工件唯一序列号', fill: '扫码枪扫入;可空(按工单整体下发)' }, - { name: '当前工位', source: '手动填写。', purpose: '当前要下发的工位(1~12)', fill: '输入 1~12 的整数' }, - { name: '工位组合', source: '勾选 12 个工位。通常与工单的工位组合一致。', purpose: '该工件要经过的工位,PLC 控制停靠', fill: '勾选即可,按工位号顺序执行' } + { name: '工单号', source: '下拉选择/输入。来自工单。', purpose: '当前生产的工单,选中后带出该工单可下发的工件 SN', fill: '选择或输入工单号' }, + { name: '工件SN', source: '下拉选择(该工单已上线未完工的 SN,可搜索),也可扫码枪扫入手输。', purpose: '当前流经的工件唯一序列号', fill: '优先下拉选已上线 SN;扫码手输时须是已上线的工件才能带出当前工位' }, + { name: '当前工位', source: '自动带出(只读)。按所选工件的实际生产进度识别。', purpose: '从哪一站开始继续下发', fill: '无需填写;未带出说明工件未上线或 SN 有误' }, + { name: '工位组合', source: '勾选 12 个工位;≤当前工位的编号已禁选(视为完成)。', purpose: '该工件还要经过的工位,PLC 控制停靠', fill: '勾选剩余要走的工位即可,按工位号顺序执行' } ] } export const helpTorque = { - title: '拧紧数据(查询/录入)', + title: '拧紧数据(补录 / 记录查询)', overview: - '接收丹尼科尔拧紧工具的采集结果(扭矩/角度/时间/结果/操作人),用于质量追溯。\n数据在工位终端点"工位完成上报"后由拧紧枪数据同步到 MES。本页可查询,也可手工补录。', + '接收丹尼科尔拧紧工具的采集结果(扭矩/角度/时间/结果/操作人),用于质量追溯。\n\n页面分两个页签:「拧紧补录」(默认打开) 补录设备漏传/手工修正的历史数据;「记录查询」(点击才加载) 按 SN / 工单号(均不区分大小写) 查询拧紧记录。\n\n实时采集不在本页:数据在工位终端/PLC 报工时由拧紧枪自动同步到 MES;本页补录仅用于设备漏传或手工修正历史,补录记录操作人自动标记「(补录)」并写入操作日志。', fields: [ - { name: 'SN', source: '扫码枪/手工。来自工件条码。', purpose: '被拧紧的工件唯一序列号', fill: '扫码枪扫描' }, - { name: '工单号', source: '自动带出/选择。来自工单。', purpose: '该工件所属工单', fill: '选择工单号' }, - { name: '工位', source: '手动填写。', purpose: '拧紧发生在哪道工位', fill: '如 3' }, - { name: '扭矩', source: '拧紧枪自动采集(丹尼科尔工具)。', purpose: '实际拧紧扭矩(N·m),判定是否达标', fill: '工具自动带出;补录时手填' }, - { name: '角度', source: '拧紧枪自动采集。', purpose: '实际旋转角度(°),判定滑牙/屈服', fill: '工具自动带出;补录时手填' }, - { name: '操作人', source: '登录账号自动带出。', purpose: '执行拧紧的人,用于追溯', fill: '默认当前登录用户,可改' } + { name: '工单号 / SN', source: '补录必填,手工填写。', purpose: '补录记录挂靠的工单与工件', fill: '设备漏传时补填对应工单号与 SN' }, + { name: '工位', source: '手工填写。', purpose: '拧紧发生在哪道工位', fill: '如 5,可空' }, + { name: '螺丝号', source: '手工填写。', purpose: '同一工件多颗螺丝时区分第几颗', fill: '如 S1,可空' }, + { name: '扭矩(N·m) / 角度(°)', source: '正常由拧紧枪自动采集;补录时手工填写。', purpose: '实际拧紧扭矩与旋转角度,判定是否达标', fill: '按实际值填写' }, + { name: '结果', source: '单选 OK/NG。', purpose: '拧紧判定结果', fill: '默认 OK' }, + { name: '补录原因', source: '手工填写,必填。', purpose: '说明为何补录,留痕审计', fill: '如:设备漏传 / 手工修正' }, + { name: '查询(SN / 工单号)', source: '「记录查询」页签筛选条件,不区分大小写。', purpose: '只看指定工件/工单的拧紧记录', fill: '可空=全部' } ] } export const helpScan = { title: '手动报工(工位工序步骤完成上报)', overview: - '每个工位完成本工位的工序步骤后,在【手动报工】页选择工位、扫入工件SN,系统按该工位「启用」的工艺流程自动展开其工序步骤(扭矩/角度/尺寸等采集项),人工录入并提交。\n提交后写报工实绩 + 步骤数据,系统按步骤考核标准自动判定 OK/NG。\n\n数据链路:工艺流程(为工位维护工序步骤与考核标准) → 手动报工页选工位扫SN → 自动载入该工位工序步骤 → 逐参数录入 → 判 OK/NG → 工件追溯可见。', + '页面分两个页签:「报工录入」(默认打开)、「报工记录」(点击才加载,分页)。\n\n录入流程:选择工位、扫入/输入工件 SN 后,系统自动载入该工位「启用」工艺流程的工序步骤(扭矩/角度/尺寸等采集项),逐参数录入提交;提交后写报工实绩 + 步骤数据,系统按考核标准自动判定 OK/NG。\n\n装机绑定:若该产品在本工序配置了需绑定的装配物料(BOM「装配工序」),会出现装机绑定区——精密件扫 SN、结构件扫/输批次号,逐项绑齐(已绑/需绑)后才允许提交报工;未配置物料则不校验。\n\n数据链路:工艺流程(工序步骤+考核标准) + BOM 装机配置 → 本页选工位扫 SN 自动载入 → 绑料+录参数 → 判 OK/NG → 工件追溯可见。', fields: [ - { name: '工位', source: '下拉选择(1~12)。', purpose: '哪个工位在报工,自动带出该工位的工序步骤', fill: '选择工位 1~12' }, - { name: '工件SN', source: '扫码枪扫描。来自工件条码。', purpose: '工件的唯一序列号,报工对象', fill: '扫码枪扫入,触发载入工序步骤' }, - { name: '各步骤采集值', source: '手工填写 或 拧紧枪自动带出(视采集方式)。字段由【工艺流程】的工序步骤人为定义。', purpose: '收集该工位的扭矩/角度/尺寸等参数,按标准判定合格与否', fill: '逐条填采集值,未维护标准的步骤仅记录' } + { name: '工位', source: '下拉选择(1~12)。', purpose: '哪个工位在报工,选择后自动载入该工位的工序步骤', fill: '选择工位 1~12' }, + { name: '工件SN', source: '扫码枪扫描或手输。来自工件条码。', purpose: '工件的唯一序列号,报工对象', fill: '扫码枪扫入,与工位一起触发自动载入' }, + { name: '各步骤采集值', source: '手工填写 或 拧紧枪自动带出(视采集方式)。字段由【工艺流程】的工序步骤人为定义。', purpose: '收集该工位的扭矩/角度/尺寸等参数,按标准判定合格与否', fill: '逐条填采集值,未维护标准的步骤仅记录' }, + { name: '装机绑定(物料/已绑/需绑)', source: '来自 BOM 的「装配工序」配置(按工单锁定的 BOM 过滤)。', purpose: '该工件本工序应装哪些料;精密件按 SN、结构件按批次绑定,齐套后才允许报工', fill: '在绑定输入框扫码或录入后点「绑定」,绑齐后提交报工' }, + { name: '报工记录查询(SN / 工单号)', source: '「报工记录」页签筛选条件,分页查看。', purpose: '查历史报工实绩', fill: '可空=全部' } ] } @@ -255,10 +260,11 @@ export const helpProcessFlow = { export const helpPerformance = { title: '绩效报表(工人工作量统计)', overview: - '按 操作人 × 日期 × 工位 汇总每个工人的完成/合格/NG 数量,用于工作量与绩效统计。\n\n页面提供「按人 / 按工位 / 明细」三个视图切换:按人看每人汇总,按工位看每工位汇总,明细看逐条记录;三者均受上方筛选条件约束,顶部汇总卡为当前筛选的总计。\n\n数据来源:全部由工位终端/手动报工的「工位完成上报」自动写入报工实绩(workpiece_process),本页只读统计,不手工录入。\n\n数据链路:工位终端报工(写报工实绩) → 本页按人/天/工位聚合 → 出报表。', + '按 操作人 × 日期 × 工位 汇总每个工人的完成/合格/NG 数量,用于工作量与绩效统计。\n\n页面提供「按人 / 按工位 / 明细」三个页签:按人看每人汇总,按工位看每工位汇总,明细看逐条记录(含工序名);三个视图各自独立分页,均受上方筛选条件约束。\n\n筛选与导出:支持 操作人 / 工位 / 日期范围 组合筛选(默认近 90 天);顶部汇总卡随查询刷新;「导出 xlsx」一次导出三个 sheet(按人/按工位/明细),导出遵循统一时间硬规则(时间范围为空默认近 3 个月、只传一端报错、跨度超 1 年报错)。\n\n数据来源:全部由工位终端/手动报工的「工位完成上报」自动写入报工实绩(workpiece_process),本页只读统计,不手工录入。', fields: [ { name: '操作人', source: '筛选条件。来自报工实绩的 operator 字段(工位终端登录人)。', purpose: '只看某个工人的工作量', fill: '输入姓名/账号,可空=全部' }, - { name: '日期范围', source: '筛选条件。来自报工实绩的产生时间。', purpose: '按时间段统计', fill: '选择起止日期,可空=全部' }, + { name: '工位', source: '下拉选择(工位1~工位12)。', purpose: '只看某个工位的报工情况', fill: '可空=全部工位' }, + { name: '日期范围', source: '筛选条件。来自报工实绩的产生时间,默认近 90 天。', purpose: '按时间段统计', fill: '选择起止日期;导出时同一范围' }, { name: '完成数', source: '自动汇总。该 操作人×日期×工位 的报工次数。', purpose: '工作量核心指标', fill: '只读' }, { name: '合格数/NG数', source: '自动汇总。按报工实绩 result 字段(OK/NG)分类计数。', purpose: '质量指标,OK+NG=完成数', fill: '只读' }, { name: '合格率', source: '自动计算 = 合格数/完成数。', purpose: '质量表现', fill: '只读' } diff --git a/bj_power_mes/frontend/src/layouts/MainLayout.vue b/bj_power_mes/frontend/src/layouts/MainLayout.vue index 6834629..d13efb7 100644 --- a/bj_power_mes/frontend/src/layouts/MainLayout.vue +++ b/bj_power_mes/frontend/src/layouts/MainLayout.vue @@ -137,7 +137,7 @@ const menuGroups = [ title: '基础配置', icon: Box, children: [ { code: 'produce.processflow', name: '工艺流程', path: '/process-flow', icon: Operation }, { code: 'produce.station', name: '关联工位', path: '/station', icon: Link }, - { code: 'produce.product', name: '产品类型', path: '/product-type', icon: Box } + { 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 f74622b..f9b5b8d 100644 --- a/bj_power_mes/frontend/src/pages/AccountManage.vue +++ b/bj_power_mes/frontend/src/pages/AccountManage.vue @@ -22,6 +22,12 @@ {{ roleName(row) }} + + + - - -