# `Fun_up_workOrderProcessId` (function)

> 获取上工序ID


- **Type:** FUNCTION
- **Returns:** `varchar(255)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `p_sId` | `varchar(255)` |
| 2 | IN | `p_sType` | `varchar(100)` |
| 3 | IN | `p_sWorkOrderId` | `varchar(100)` |

## Body

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

## Narrative

**Business context:** Work-order process-graph walker — given a `mftworkorderprocess.sId` and the row's `sType`, returns the sId of the previous (upstream) process step in the same work-order's flow. Header gloss: "获取上工序ID" (get upstream process id).

**What it does:** When `sType='3'` (combined-parts step), first matches by `sCombinePartsName`, then by `sNextId` traversal. When `sType='0'` (origin) it returns `p_sId` itself. Otherwise looks up the row whose `sNextId` equals `p_sId`. Falls back to the input when nothing matches.

**Invocation:** Orphan-via-dead-chain. Only caller `fun_GetPreProcessQty` is itself an orphan (per session 6 audit — hardcodes a tenant `eleprocess.sId`). No form-master, module-hook, or xly-src reference. Candidate for maintainer audit.
