# `Sp_Calc_sSmc` (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_sSmc`'`._

## Narrative

**Business context:** 半成品盘点 (semi-goods stock-take — `sgdsemigoodscheckmaster`) audit / un-audit. Auditing posts the counted deltas against the perpetual semi-goods stock so the 帐面/实物 difference becomes the new book qty.

**What it does:** Validates `sGuid`/`bInvalid` and `SysLocking`, then on `iFlag=1` sets `bCheck=1`, `sCheckPerson`, `tCheckDate` on `sgdsemigoodscheckmaster` and its slave; iterates `sgdsemigoodscheckSlave`, `UPDATE elesemigoodsstock` to set the new on-hand and `INSERT INTO sgdSemigoodsStore` for the audit-trail movement row; `iFlag=0` reverses both, restoring the prior on-hand.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName` binding, no form-master `sSqlStr` ref, no other-routine caller, no xly-src grep hit. The 半成品盘点 form is wired up under a sibling proc; this looks like a legacy audit slot retained by name convention only — candidate for maintainer audit.
