# `Sp_Exec_sOutProcess` (procedure)

> 补模具发外，如果存在工序则变更发外数量，如果不存在，插入发外工序


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iFlag` | `int` |
| 2 | IN | `iTmpCheck` | `int` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sGuid` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(5000)` |
| 7 | IN | `sBrId` | `varchar(100)` |
| 8 | IN | `sSuId` | `varchar(100)` |
| 9 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** Intended to back the 补模具发外 (mould-rework outsourcing) audit on `mftoutprocessslave` — when an outsourcing row references a work-order/process pair that already exists in `mftworkorderprocess` it bumps `dOutsideQty` on that row; otherwise it inserts a new `mftworkorderprocess` row carrying the outsource qty.

**What it does:** Cursors over `mftoutprocessslave WHERE sParentId=sGuid`, looks up the matching `mftworkorderprocess` row by `(sControlId, sProcessId)`. If found, stamps `sWorkOrderProcessTbId` back on the slave row and adds `iOutsideQty` to `dOutsideQty` (with `bOutside=1, bOutSideComplete=0`). If not found, generates a new id and `INSERT INTO mftworkorderprocess` populating the full column set so the rework process exists in the plan.

**Invocation:** Called only by `Sp_Calc_sOutProcess`, which is itself orphaned — no `gdsmodule.sProcName`/`sSaveProName` binding, no form-master reference, no xly-src caller beyond the install script `script/标版/30100101/Sp_Calc_sOutProcess.sql`. Status: appears orphaned via its only caller — candidate for maintainer audit (likely a half-wired feature for mould rework that never reached production).
