feat: 完成多模块迭代更新
- 新增过程巡检按步骤上报、数量不符上报、工位退料功能 - 增加工单工程编号三级归属字段 - 新增物料安全库存与缺货预警 - 新增附件管理、退库单管理模块 - 优化生产看板展示逻辑与前端页面文案 - 清理冗余的工艺路线相关代码与备份文件
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -22,6 +23,7 @@ type StepCriterionQuery struct {
|
||||
order []stepcriterion.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.StepCriterion
|
||||
modifiers []func(*sql.Selector)
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@@ -251,8 +253,9 @@ func (_q *StepCriterionQuery) Clone() *StepCriterionQuery {
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.StepCriterion{}, _q.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,6 +346,9 @@ func (_q *StepCriterionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
@@ -357,6 +363,9 @@ func (_q *StepCriterionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([
|
||||
|
||||
func (_q *StepCriterionQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
@@ -419,6 +428,9 @@ func (_q *StepCriterionQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
@@ -436,6 +448,38 @@ func (_q *StepCriterionQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
return selector
|
||||
}
|
||||
|
||||
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
|
||||
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
|
||||
// either committed or rolled-back.
|
||||
func (_q *StepCriterionQuery) ForUpdate(opts ...sql.LockOption) *StepCriterionQuery {
|
||||
if _q.driver.Dialect() == dialect.Postgres {
|
||||
_q.Unique(false)
|
||||
}
|
||||
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
|
||||
s.ForUpdate(opts...)
|
||||
})
|
||||
return _q
|
||||
}
|
||||
|
||||
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
|
||||
// on any rows that are read. Other sessions can read the rows, but cannot modify them
|
||||
// until your transaction commits.
|
||||
func (_q *StepCriterionQuery) ForShare(opts ...sql.LockOption) *StepCriterionQuery {
|
||||
if _q.driver.Dialect() == dialect.Postgres {
|
||||
_q.Unique(false)
|
||||
}
|
||||
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
|
||||
s.ForShare(opts...)
|
||||
})
|
||||
return _q
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (_q *StepCriterionQuery) Modify(modifiers ...func(s *sql.Selector)) *StepCriterionSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// StepCriterionGroupBy is the group-by builder for StepCriterion entities.
|
||||
type StepCriterionGroupBy struct {
|
||||
selector
|
||||
@@ -525,3 +569,9 @@ func (_s *StepCriterionSelect) sqlScan(ctx context.Context, root *StepCriterionQ
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (_s *StepCriterionSelect) Modify(modifiers ...func(s *sql.Selector)) *StepCriterionSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user