# `Sp_Calc_sEmmt` (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(5000)` |
| 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_sEmmt`'`._

## Narrative

**Business context:** 设备管理 → 设备单据 → 设备维修 — equipment-maintenance check / uncheck on `eptmachinemaintenancemaster`. Approves a 设备维修 (repair/maintenance record) so it becomes the official record for the machine downtime + parts/labor cost rollup.

**What it does:** Validates `sGuid`, refuses when `bInvalid=1`. With `iFlag=1`: guards on already-`bCheck=1` then `Update eptmachinemaintenancemaster` setting `bCheck=1, sStatus=1, sCheckPerson, tCheckDate`. With `iFlag<>1`: symmetric uncheck. Standard thin `Sp_Calc_s<Code>` audit shape — no slave-cursor, no downstream back-write.

**Invocation:** Bound to `gdsmodule.sProcName` on `设备维修` (sId `101251240115016055988358370`), parent `设备单据` → 设备管理. Dispatched by Java `BusinessBaseServiceImpl.getPrcName(...)` on the audit/un-audit button. xly-src ships `script/标版/30100101/Sp_Calc_sEmmt.sql` (install) and `script/标版/optimize/Sp_Calc_sEmmt.sql` (patch).

Note: the COMMENT on the proc reads `'商机跟进'` (sales-lead follow-up), copy-pasted from an unrelated template — purely cosmetic, ignore.
