# `fun_getWorkProcess_NextIdnew` (function)

> 获取工单下工序ID


- **Type:** FUNCTION
- **Returns:** `longtext`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `p_sWorkOrderControlId` | `varchar(255)` |
| 2 | IN | `p_sWorkOrderSlaveId` | `varchar(255)` |
| 3 | IN | `sBrId` | `varchar(255)` |
| 4 | IN | `sSuId` | `varchar(255)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `fun_getWorkProcess_NextIdnew`'`._

## Narrative

**Business context:** AGV-aware variant of [`fun_getWorkProcess_NextId`](fun_getWorkProcess_NextId.md) — finds the next intermediate work-order-process step **excluding any process whose `eleprocess.bEffectAGV = 0`** (i.e. drops processes that AGV routing should skip). Starts from a `mftworkorderslave.sId` (resolves it to its parent work-order first) instead of the work-order id directly.

**What it does:** resolves `mftworkorderslave.sParentId` → `p_sWorkOrderId`. Joins `mftworkorderprocess` to `eleprocess` filtering `EP.bEffectAGV=0`, then picks the first `sType<3` step matching the given `sControlId`. Falls back to first `sType=3` (成品) step when no intermediate match.

**Invocation:** referenced by `Sp_WorkOrder_CalcDataPackPartsStd_child` alongside the non-`new` variant. No other routine, form-master sSqlStr, gdsmodule hook, or xly-src reference reaches it.
