提交
This commit is contained in:
@@ -70,7 +70,7 @@ type ProductProcessVO struct {
|
||||
|
||||
// ListProductProcesses 产品工艺列表(分页;筛选:产品编码/状态/工艺反查/关键字)。
|
||||
// page>0 真分页返回 map{total,list,page,pageSize};page=0 返回全量数组(工单页下拉用)。
|
||||
func (s *Service) ListProductProcesses(ctx context.Context, productCode, status string, flowId int, keyword string, page, pageSize int) (any, error) {
|
||||
func (s *Service) ListProductProcesses(ctx context.Context, productCode, status string, flowId int, keyword, name string, stepMin, stepMax int, page, pageSize int) (any, error) {
|
||||
q := s.ctx.EntClient.ProductProcess.Query()
|
||||
if productCode != "" {
|
||||
q = q.Where(productprocess.ProductCodeContainsFold(productCode))
|
||||
@@ -86,6 +86,9 @@ func (s *Service) ListProductProcesses(ctx context.Context, productCode, status
|
||||
)
|
||||
q = q.Where(kw)
|
||||
}
|
||||
if name != "" {
|
||||
q = q.Where(productprocess.NameContainsFold(name))
|
||||
}
|
||||
// 工艺反查:只要包含该工艺的产品工艺
|
||||
if flowId > 0 {
|
||||
items, err := s.ctx.EntClient.ProductProcessItem.Query().
|
||||
@@ -161,6 +164,21 @@ func (s *Service) ListProductProcesses(ctx context.Context, productCode, status
|
||||
vo.Executable, vo.NotReady = ppExecutable(vo)
|
||||
out = append(out, vo)
|
||||
}
|
||||
// 工序数范围过滤:按产品工艺的工艺顺序/工序条目数(vo.Flows 长度)
|
||||
if stepMin > 0 || stepMax > 0 {
|
||||
kept := make([]*ProductProcessVO, 0, len(out))
|
||||
for _, vo := range out {
|
||||
n := len(vo.Flows)
|
||||
if stepMin > 0 && n < stepMin {
|
||||
continue
|
||||
}
|
||||
if stepMax > 0 && n > stepMax {
|
||||
continue
|
||||
}
|
||||
kept = append(kept, vo)
|
||||
}
|
||||
out = kept
|
||||
}
|
||||
if page > 0 {
|
||||
total := len(out)
|
||||
start := (page - 1) * pageSize
|
||||
|
||||
Reference in New Issue
Block a user