# `Sp_Calc_sSgm` (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_sSgm`'`._

## Narrative

**Business context:** 生产管理 → 装配工艺卡 (assembly process card — `sgdsemigoodsmatchmaster`) audit / un-audit. The 装配工艺卡 captures the per-process route for a semi-goods assembly bill; auditing locks the route so downstream work-orders can consume it.

**What it does:** Validates `sGuid`/`bInvalid`, then on `iFlag=1` sets `bCheck=1`, `sCheckPerson`, `tCheckDate` on `sgdsemigoodsmatchmaster`; reads `eleprocess` for process metadata and writes `sgdsemigoodsmatchprocess` to fill in process refs / sequencing. `iFlag=0` reverses the flag and the writeback.

**Invocation:** Bound to `gdsmodule.sProcName` on `装配工艺卡` (sId `101251240115015942008559830`) — 制造管理. Dispatched by `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the 审核/反审核 button. Despite the page comment "发外检验" (outsourced-inspection), the actual deployed body targets the assembly-process-card master — verify both the comment and any customer override.

Flag: page comment `发外检验` does not match the deployed body (which targets `sgdsemigoodsmatchmaster`, an assembly-route bill). One of the two is stale — candidate for maintainer audit.
