# `fun_getWorkProcess_NextId` (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_sWorkOrderId` | `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_NextId`'`._

## Narrative

**Business context:** Next work-order-process probe — for a given work-order + control-row, returns the `sId` of the first `mftworkorderprocess` whose `sType < 3` (intermediate stage). Falls back to the first `sType=3` (成品) step when no intermediate exists. Used by parts/components std-calc routines to figure out "which process picks up this material next?"

**What it does:** `SELECT sId FROM mftworkorderprocess WHERE sParentId=p_sWorkOrderId AND sControlId=p_sWorkOrderControlId AND sType<3 ORDER BY iOrder LIMIT 1`; on empty, retries with `sType=3`.

**Invocation:** referenced by `Sp_WorkOrder_CalcDataPackPartsStd_child` (work-order parts/component standards aggregator). No form-master or gdsmodule hook reaches it directly — it is a building block of the parts-std calc chain.
