# `Sp_Calc_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_Calc_sOutProcess`'`._

## Narrative

**Business context:** Audit handler for 补模具发外 (supplementary mould outsource-dispatch) on `mftoutprocessmaster` — the supplementary-dispatch master that books extra 工序 to a vendor when the planned outsource quantity was insufficient. On approval it freezes the master/slave rows and chains to `Sp_Exec_sOutProcess` to apply the qty roll-up; on un-audit it rolls back the dispatch quantity on `mftworkorderprocess`.

**What it does:** Validates `sGuid`, refuses re-audit when `bCheck=1`, sets `bCheck=1, sStatus=1, sCheckPerson, tCheckDate=NOW()` on `mftoutprocessmaster`, then `CALL Sp_Exec_sOutProcess(iFlag, iTmpCheck, sFormGuid, sGuid, sLoginId, @sReturn, sBrId, sSuId, @sCode)` to execute the dispatch-qty roll-up. Reverse branch (`iFlag=0`) zeroes the audit fields and joins `mftoutprocessslave` to `mftworkorderprocess` to subtract `dOutsideQty -= iOutsideQty`.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName/sSaveProName`, `gdsconfigformmaster` form-master, sibling routine, or xly-src reference points at `Sp_Calc_sOutProcess`. Candidate for maintainer audit; `Sp_Exec_sOutProcess` is also referenced by name only and may share the same fate.
