refactor: 重构工艺工序相关命名与数据模型
1. 全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2. 重构工单与工件工艺数据模型:
- 新增工艺组合表flow_material作为备料/齐套唯一源头
- 新增工位状态表station_state支持自主停单/恢复接单
- 移除station_process派工表,改用工单工艺组合作为路线唯一源头
- 替换processCode为flowId作为工艺关联标识
- 重构工件当前进度字段为currentStationNo
3. 删除冗余的静态备份资源文件
4. 调整物料选择组件默认启用仅显示激活物料
5. 优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
@@ -0,0 +1,482 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"bj_power_mes/ent/predicate"
|
||||
"bj_power_mes/ent/stationstate"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// StationStateUpdate is the builder for updating StationState entities.
|
||||
type StationStateUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *StationStateMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the StationStateUpdate builder.
|
||||
func (_u *StationStateUpdate) Where(ps ...predicate.StationState) *StationStateUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStationNo sets the "stationNo" field.
|
||||
func (_u *StationStateUpdate) SetStationNo(v int) *StationStateUpdate {
|
||||
_u.mutation.ResetStationNo()
|
||||
_u.mutation.SetStationNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
||||
func (_u *StationStateUpdate) SetNillableStationNo(v *int) *StationStateUpdate {
|
||||
if v != nil {
|
||||
_u.SetStationNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddStationNo adds value to the "stationNo" field.
|
||||
func (_u *StationStateUpdate) AddStationNo(v int) *StationStateUpdate {
|
||||
_u.mutation.AddStationNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDate sets the "date" field.
|
||||
func (_u *StationStateUpdate) SetDate(v string) *StationStateUpdate {
|
||||
_u.mutation.SetDate(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDate sets the "date" field if the given value is not nil.
|
||||
func (_u *StationStateUpdate) SetNillableDate(v *string) *StationStateUpdate {
|
||||
if v != nil {
|
||||
_u.SetDate(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPaused sets the "paused" field.
|
||||
func (_u *StationStateUpdate) SetPaused(v bool) *StationStateUpdate {
|
||||
_u.mutation.SetPaused(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePaused sets the "paused" field if the given value is not nil.
|
||||
func (_u *StationStateUpdate) SetNillablePaused(v *bool) *StationStateUpdate {
|
||||
if v != nil {
|
||||
_u.SetPaused(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetReason sets the "reason" field.
|
||||
func (_u *StationStateUpdate) SetReason(v string) *StationStateUpdate {
|
||||
_u.mutation.SetReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableReason sets the "reason" field if the given value is not nil.
|
||||
func (_u *StationStateUpdate) SetNillableReason(v *string) *StationStateUpdate {
|
||||
if v != nil {
|
||||
_u.SetReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOperator sets the "operator" field.
|
||||
func (_u *StationStateUpdate) SetOperator(v string) *StationStateUpdate {
|
||||
_u.mutation.SetOperator(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
||||
func (_u *StationStateUpdate) SetNillableOperator(v *string) *StationStateUpdate {
|
||||
if v != nil {
|
||||
_u.SetOperator(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updatedAt" field.
|
||||
func (_u *StationStateUpdate) SetUpdatedAt(v time.Time) *StationStateUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
||||
func (_u *StationStateUpdate) ClearUpdatedAt() *StationStateUpdate {
|
||||
_u.mutation.ClearUpdatedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the StationStateMutation object of the builder.
|
||||
func (_u *StationStateUpdate) Mutation() *StationStateMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *StationStateUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *StationStateUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *StationStateUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *StationStateUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *StationStateUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
||||
v := stationstate.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *StationStateUpdate) check() error {
|
||||
if v, ok := _u.mutation.Date(); ok {
|
||||
if err := stationstate.DateValidator(v); err != nil {
|
||||
return &ValidationError{Name: "date", err: fmt.Errorf(`ent: validator failed for field "StationState.date": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Reason(); ok {
|
||||
if err := stationstate.ReasonValidator(v); err != nil {
|
||||
return &ValidationError{Name: "reason", err: fmt.Errorf(`ent: validator failed for field "StationState.reason": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Operator(); ok {
|
||||
if err := stationstate.OperatorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationState.operator": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *StationStateUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationStateUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *StationStateUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(stationstate.Table, stationstate.Columns, sqlgraph.NewFieldSpec(stationstate.FieldID, field.TypeInt))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.StationNo(); ok {
|
||||
_spec.SetField(stationstate.FieldStationNo, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedStationNo(); ok {
|
||||
_spec.AddField(stationstate.FieldStationNo, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Date(); ok {
|
||||
_spec.SetField(stationstate.FieldDate, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Paused(); ok {
|
||||
_spec.SetField(stationstate.FieldPaused, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Reason(); ok {
|
||||
_spec.SetField(stationstate.FieldReason, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Operator(); ok {
|
||||
_spec.SetField(stationstate.FieldOperator, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(stationstate.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.UpdatedAtCleared() {
|
||||
_spec.ClearField(stationstate.FieldUpdatedAt, field.TypeTime)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{stationstate.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// StationStateUpdateOne is the builder for updating a single StationState entity.
|
||||
type StationStateUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *StationStateMutation
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetStationNo sets the "stationNo" field.
|
||||
func (_u *StationStateUpdateOne) SetStationNo(v int) *StationStateUpdateOne {
|
||||
_u.mutation.ResetStationNo()
|
||||
_u.mutation.SetStationNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStationNo sets the "stationNo" field if the given value is not nil.
|
||||
func (_u *StationStateUpdateOne) SetNillableStationNo(v *int) *StationStateUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetStationNo(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddStationNo adds value to the "stationNo" field.
|
||||
func (_u *StationStateUpdateOne) AddStationNo(v int) *StationStateUpdateOne {
|
||||
_u.mutation.AddStationNo(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDate sets the "date" field.
|
||||
func (_u *StationStateUpdateOne) SetDate(v string) *StationStateUpdateOne {
|
||||
_u.mutation.SetDate(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDate sets the "date" field if the given value is not nil.
|
||||
func (_u *StationStateUpdateOne) SetNillableDate(v *string) *StationStateUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDate(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPaused sets the "paused" field.
|
||||
func (_u *StationStateUpdateOne) SetPaused(v bool) *StationStateUpdateOne {
|
||||
_u.mutation.SetPaused(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePaused sets the "paused" field if the given value is not nil.
|
||||
func (_u *StationStateUpdateOne) SetNillablePaused(v *bool) *StationStateUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetPaused(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetReason sets the "reason" field.
|
||||
func (_u *StationStateUpdateOne) SetReason(v string) *StationStateUpdateOne {
|
||||
_u.mutation.SetReason(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableReason sets the "reason" field if the given value is not nil.
|
||||
func (_u *StationStateUpdateOne) SetNillableReason(v *string) *StationStateUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetReason(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetOperator sets the "operator" field.
|
||||
func (_u *StationStateUpdateOne) SetOperator(v string) *StationStateUpdateOne {
|
||||
_u.mutation.SetOperator(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableOperator sets the "operator" field if the given value is not nil.
|
||||
func (_u *StationStateUpdateOne) SetNillableOperator(v *string) *StationStateUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetOperator(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updatedAt" field.
|
||||
func (_u *StationStateUpdateOne) SetUpdatedAt(v time.Time) *StationStateUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
||||
func (_u *StationStateUpdateOne) ClearUpdatedAt() *StationStateUpdateOne {
|
||||
_u.mutation.ClearUpdatedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the StationStateMutation object of the builder.
|
||||
func (_u *StationStateUpdateOne) Mutation() *StationStateMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the StationStateUpdate builder.
|
||||
func (_u *StationStateUpdateOne) Where(ps ...predicate.StationState) *StationStateUpdateOne {
|
||||
_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 *StationStateUpdateOne) Select(field string, fields ...string) *StationStateUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated StationState entity.
|
||||
func (_u *StationStateUpdateOne) Save(ctx context.Context) (*StationState, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *StationStateUpdateOne) SaveX(ctx context.Context) *StationState {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *StationStateUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *StationStateUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *StationStateUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
||||
v := stationstate.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *StationStateUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Date(); ok {
|
||||
if err := stationstate.DateValidator(v); err != nil {
|
||||
return &ValidationError{Name: "date", err: fmt.Errorf(`ent: validator failed for field "StationState.date": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Reason(); ok {
|
||||
if err := stationstate.ReasonValidator(v); err != nil {
|
||||
return &ValidationError{Name: "reason", err: fmt.Errorf(`ent: validator failed for field "StationState.reason": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Operator(); ok {
|
||||
if err := stationstate.OperatorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "operator", err: fmt.Errorf(`ent: validator failed for field "StationState.operator": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (_u *StationStateUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *StationStateUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (_u *StationStateUpdateOne) sqlSave(ctx context.Context) (_node *StationState, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(stationstate.Table, stationstate.Columns, sqlgraph.NewFieldSpec(stationstate.FieldID, field.TypeInt))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "StationState.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, stationstate.FieldID)
|
||||
for _, f := range fields {
|
||||
if !stationstate.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != stationstate.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.StationNo(); ok {
|
||||
_spec.SetField(stationstate.FieldStationNo, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AddedStationNo(); ok {
|
||||
_spec.AddField(stationstate.FieldStationNo, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Date(); ok {
|
||||
_spec.SetField(stationstate.FieldDate, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Paused(); ok {
|
||||
_spec.SetField(stationstate.FieldPaused, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Reason(); ok {
|
||||
_spec.SetField(stationstate.FieldReason, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Operator(); ok {
|
||||
_spec.SetField(stationstate.FieldOperator, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(stationstate.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.UpdatedAtCleared() {
|
||||
_spec.ClearField(stationstate.FieldUpdatedAt, field.TypeTime)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &StationState{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{stationstate.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
Reference in New Issue
Block a user