# `Sp_saveReturn_sOis` (procedure)

> 工序发外确认单据反写


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `longtext` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `iTag` | `int` |
| 5 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `longtext` |

## Body

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

## Narrative

**Business context:** KPI流程操作菜单 → 发外加工流程 → 工序发外确认 (and mobile variants 发外报工(mobile单据) and 工序发外确认单据 under 移动端管理 → 现场 → 功能操作) — when an outsourcing-process confirmation (`opsoutsideinstoremaster`) is saved, back-writes the confirmed in-store qty onto upstream 工序发外 lines, the originating 工单工序 (`MftWorkOrderProcess`), and the linked 工序检验 (`Qlyoutsideproducttestmaster`).

**What it does:** Splits `sGuid` into `p_t_sId`, builds two source-id sets — `p_sSrcSlaveId_tmp` (for `OpsOutsideProcessSlave.sId`), `p_sWorkOrderProcessTbId_tmp` (for `MftWorkOrderProcess.sId`), and `p_sTestSlaveId_tmp` (for `Qlyoutsideproducttestmaster.sId`) — sums confirmation figures (zeroing the in-flight batch when `iTag=1`) into `t_data_temp`, then updates each target table's already-confirmed columns.

**Invocation:** Called by `Sp_beforeSave_sOis` (`iTag=1`) and `Sp_afterSave_sOis` (`iTag=2`). The beforeSave wrapper is bound on `gdsmodule.sSaveProNameBefore` for 工序发外确认 (`192116810113315234275562360`) under 发外加工流程, and for 发外报工(mobile单据) (`101251240115015952158106410`) / 工序发外确认单据 (`101251240115016182844497490`) under 移动端管理 → 现场 → 功能操作 — fired by `BusinessBaseServiceImpl` save hooks. `Sp_Invalid_backwriting` / `Sp_delete_backwriting` re-route to `Sp_beforeSave_sOis` for the desktop form id on cancel/delete. No xly-src callers.
