# `Sp_Calc_sSmia` (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_sSmia`'`._

## Narrative

**Business context:** 半成品入库申请 (semi-goods inbound application — `sgdsemigoodsinstoreapplymaster`) audit / un-audit. The application bill pre-commits an inbound qty against a 工单 (work-order) line; auditing locks the application and back-writes the work-order process slave.

**What it does:** Validates `sGuid`/`bInvalid` and `SysLocking`, then on `iFlag=1` sets `bCheck=1`, `sCheckPerson`, `tCheckDate` on `sgdsemigoodsinstoreapplymaster`; iterates `sgdsemigoodsinstoreapplyslave` and `Update mftworkorderprocess` to mark the originating work-order process step as applied. `iFlag=0` reverses both.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName` binding, no form-master `sSqlStr` ref, no other-routine caller. xly-src carries install scripts (`script/标版/30100101/Sp_Calc_sSmia.sql`) and an optimize patch (`script/标版/optimize/Sp_Calc_sSmia.sql`) but no Java caller — the live 入库申请 form is wired up under a different proc; candidate for maintainer audit. Despite the page comment 装配工单, the deployed body targets the inbound-application master.

Flag: page comment `装配工单` does not match the deployed body (which targets `sgdsemigoodsinstoreapplymaster`). One of the two is stale — candidate for maintainer audit.
