本次提交覆盖多个业务模块的功能完善与体验优化:
1. **鉴权与配置调整**:
- 统一JWT滑动续签逻辑,简化Token存储,移除RefreshToken相关冗余代码
- 调整多项目配置文件中JWT过期时间为3600秒,统一会话闲置窗口
- 工位配置放开1~12限制,改为仅校验大于0
2. **术语统一替换**:全链路将"精密件"替换为"电气件",修正物料管理描述
3. **功能新增**:
- 新增工位类型、工艺路线与产线点位台账模块
- 添加工艺PDF预览面板、工位终端代理转发接口
- 新增操作日志按操作人列表筛选、工位登出日志记录
- 新增PLC移料指令与产线点位状态管理
4. **业务流程优化**:
- 调整BOM物料删除校验逻辑,优化工单备料计算
- 补充物料图号、检测单号等追溯字段
- 完善工艺流程图与工位绑定关系说明
- 优化前端页面文案与交互细节
5. **代码规范与维护**:
- 新增通用工具函数与前端静态资源
- 整理路由权限与中间件逻辑
- 修复部分接口与配置的不兼容问题
467 lines
14 KiB
Go
467 lines
14 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/predicate"
|
|
"bj_power_mes/ent/processroute"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// ProcessRouteUpdate is the builder for updating ProcessRoute entities.
|
|
type ProcessRouteUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *ProcessRouteMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the ProcessRouteUpdate builder.
|
|
func (_u *ProcessRouteUpdate) Where(ps ...predicate.ProcessRoute) *ProcessRouteUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *ProcessRouteUpdate) SetName(v string) *ProcessRouteUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdate) SetNillableName(v *string) *ProcessRouteUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProductTypeId sets the "productTypeId" field.
|
|
func (_u *ProcessRouteUpdate) SetProductTypeId(v int) *ProcessRouteUpdate {
|
|
_u.mutation.ResetProductTypeId()
|
|
_u.mutation.SetProductTypeId(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProductTypeId sets the "productTypeId" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdate) SetNillableProductTypeId(v *int) *ProcessRouteUpdate {
|
|
if v != nil {
|
|
_u.SetProductTypeId(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddProductTypeId adds value to the "productTypeId" field.
|
|
func (_u *ProcessRouteUpdate) AddProductTypeId(v int) *ProcessRouteUpdate {
|
|
_u.mutation.AddProductTypeId(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearProductTypeId clears the value of the "productTypeId" field.
|
|
func (_u *ProcessRouteUpdate) ClearProductTypeId() *ProcessRouteUpdate {
|
|
_u.mutation.ClearProductTypeId()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *ProcessRouteUpdate) SetStatus(v string) *ProcessRouteUpdate {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdate) SetNillableStatus(v *string) *ProcessRouteUpdate {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *ProcessRouteUpdate) SetRemark(v string) *ProcessRouteUpdate {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdate) SetNillableRemark(v *string) *ProcessRouteUpdate {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updatedAt" field.
|
|
func (_u *ProcessRouteUpdate) SetUpdatedAt(v time.Time) *ProcessRouteUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
|
func (_u *ProcessRouteUpdate) ClearUpdatedAt() *ProcessRouteUpdate {
|
|
_u.mutation.ClearUpdatedAt()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the ProcessRouteMutation object of the builder.
|
|
func (_u *ProcessRouteUpdate) Mutation() *ProcessRouteMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *ProcessRouteUpdate) 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 *ProcessRouteUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *ProcessRouteUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProcessRouteUpdate) 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 *ProcessRouteUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
|
v := processroute.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProcessRouteUpdate) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := processroute.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProcessRoute.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := processroute.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ProcessRoute.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := processroute.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessRoute.remark": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProcessRouteUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProcessRouteUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProcessRouteUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(processroute.Table, processroute.Columns, sqlgraph.NewFieldSpec(processroute.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.Name(); ok {
|
|
_spec.SetField(processroute.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProductTypeId(); ok {
|
|
_spec.SetField(processroute.FieldProductTypeId, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedProductTypeId(); ok {
|
|
_spec.AddField(processroute.FieldProductTypeId, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.ProductTypeIdCleared() {
|
|
_spec.ClearField(processroute.FieldProductTypeId, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(processroute.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(processroute.FieldRemark, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(processroute.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdatedAtCleared() {
|
|
_spec.ClearField(processroute.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{processroute.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// ProcessRouteUpdateOne is the builder for updating a single ProcessRoute entity.
|
|
type ProcessRouteUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *ProcessRouteMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *ProcessRouteUpdateOne) SetName(v string) *ProcessRouteUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdateOne) SetNillableName(v *string) *ProcessRouteUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProductTypeId sets the "productTypeId" field.
|
|
func (_u *ProcessRouteUpdateOne) SetProductTypeId(v int) *ProcessRouteUpdateOne {
|
|
_u.mutation.ResetProductTypeId()
|
|
_u.mutation.SetProductTypeId(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProductTypeId sets the "productTypeId" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdateOne) SetNillableProductTypeId(v *int) *ProcessRouteUpdateOne {
|
|
if v != nil {
|
|
_u.SetProductTypeId(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddProductTypeId adds value to the "productTypeId" field.
|
|
func (_u *ProcessRouteUpdateOne) AddProductTypeId(v int) *ProcessRouteUpdateOne {
|
|
_u.mutation.AddProductTypeId(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearProductTypeId clears the value of the "productTypeId" field.
|
|
func (_u *ProcessRouteUpdateOne) ClearProductTypeId() *ProcessRouteUpdateOne {
|
|
_u.mutation.ClearProductTypeId()
|
|
return _u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_u *ProcessRouteUpdateOne) SetStatus(v string) *ProcessRouteUpdateOne {
|
|
_u.mutation.SetStatus(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdateOne) SetNillableStatus(v *string) *ProcessRouteUpdateOne {
|
|
if v != nil {
|
|
_u.SetStatus(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_u *ProcessRouteUpdateOne) SetRemark(v string) *ProcessRouteUpdateOne {
|
|
_u.mutation.SetRemark(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_u *ProcessRouteUpdateOne) SetNillableRemark(v *string) *ProcessRouteUpdateOne {
|
|
if v != nil {
|
|
_u.SetRemark(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updatedAt" field.
|
|
func (_u *ProcessRouteUpdateOne) SetUpdatedAt(v time.Time) *ProcessRouteUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
|
func (_u *ProcessRouteUpdateOne) ClearUpdatedAt() *ProcessRouteUpdateOne {
|
|
_u.mutation.ClearUpdatedAt()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the ProcessRouteMutation object of the builder.
|
|
func (_u *ProcessRouteUpdateOne) Mutation() *ProcessRouteMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the ProcessRouteUpdate builder.
|
|
func (_u *ProcessRouteUpdateOne) Where(ps ...predicate.ProcessRoute) *ProcessRouteUpdateOne {
|
|
_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 *ProcessRouteUpdateOne) Select(field string, fields ...string) *ProcessRouteUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated ProcessRoute entity.
|
|
func (_u *ProcessRouteUpdateOne) Save(ctx context.Context) (*ProcessRoute, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *ProcessRouteUpdateOne) SaveX(ctx context.Context) *ProcessRoute {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *ProcessRouteUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *ProcessRouteUpdateOne) 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 *ProcessRouteUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
|
v := processroute.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *ProcessRouteUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := processroute.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProcessRoute.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Status(); ok {
|
|
if err := processroute.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ProcessRoute.status": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Remark(); ok {
|
|
if err := processroute.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessRoute.remark": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *ProcessRouteUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ProcessRouteUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *ProcessRouteUpdateOne) sqlSave(ctx context.Context) (_node *ProcessRoute, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(processroute.Table, processroute.Columns, sqlgraph.NewFieldSpec(processroute.FieldID, field.TypeInt))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ProcessRoute.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, processroute.FieldID)
|
|
for _, f := range fields {
|
|
if !processroute.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != processroute.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.Name(); ok {
|
|
_spec.SetField(processroute.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProductTypeId(); ok {
|
|
_spec.SetField(processroute.FieldProductTypeId, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedProductTypeId(); ok {
|
|
_spec.AddField(processroute.FieldProductTypeId, field.TypeInt, value)
|
|
}
|
|
if _u.mutation.ProductTypeIdCleared() {
|
|
_spec.ClearField(processroute.FieldProductTypeId, field.TypeInt)
|
|
}
|
|
if value, ok := _u.mutation.Status(); ok {
|
|
_spec.SetField(processroute.FieldStatus, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Remark(); ok {
|
|
_spec.SetField(processroute.FieldRemark, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(processroute.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.UpdatedAtCleared() {
|
|
_spec.ClearField(processroute.FieldUpdatedAt, field.TypeTime)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &ProcessRoute{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{processroute.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|