# `Sp_Calc_sOis` (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(4000)` |
| 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_sOis`'`._

## Narrative

**Business context:** 发外加工流程 / 移动端管理 → 发外加工确认 — outsourced-process confirmation audit / un-audit on `OpsOutsideProcessSlave`/`OpsOutsideInStoreMaster`. Bound on three modules: `工序发外确认`, `发外报工(mobile单据)`, and `工序发外确认单据`. Approving a confirmation commits that the outsourced step has returned and is acceptable to count against the work-order progress and (if knife-mould tooling was loaned) updates the tool's location/inventory.

**What it does:** Defaults the IN params, branches on `iFlag`. On `iFlag=1` flips `OpsOutsideProcessSlave.bCheck=1`, `Update MftWorkOrderProcess` to back-write the confirmed completed qty onto the work-order's process slave (advancing the route), `Update OpsOutsideInStoreMaster` to mark the inbound row checked, and `Update QlyOutSideProductTestSlave` to seed the QC inspection rows. If knife-moulds were issued: `INSERT INTO EleKnifeMould`/`eleknifemouldproduct` + `UPDATE EleKnifeMould` to track the tool returning to in-house custody. `iFlag=0` reverses each.

**Invocation:** Bound to `gdsmodule.sProcName` on three modules: `工序发外确认` (sId `192116810113315234275562360`) under 发外加工流程, `发外报工(mobile单据)` (sId `101251240115015952158106410`) and `工序发外确认单据` (sId `101251240115016182844497490`) under 移动端管理 → 功能操作. All three share `Sp_Check_sOis` / `Sp_beforeSave_sOis`. Dispatched by Java `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on 审核/反审核. xly-src ships `script/标版/30100101/Sp_Calc_sOis.sql`, `script/标版/optimize/Sp_Calc_sOis.sql`, an upgrade patch under `script/标版/upgrade/20220126-2861-仓库冻结后，入库、领料、送货单不可消审/`, and a customer-override at `script/客户/千彩/Sp_Calc_sOis.sql` — confirm which is deployed before relying on the optimize variant.
