# `Sp_Calc_sPct3` (procedure)

> @author:zhucx
							@date:2021.11.21 封存
							@describe: 
							1.OEE端-生产首检-保存自动调用本过程,当系统设定中本单据为自动审核时


- **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_sPct3`'`._

## Narrative

**Business context:** OEE管理 → 机长首检登记(OEE) — audit handler for the OEE-side 生产首检 doc on `QlyProcessTestMaster`. Header authorship: `zhucx 2021.11.21 封存`. The OEE machine-data flow lets the machine operator (机长) self-register a first-piece inspection from the OEE terminal; on approval this proc freezes the inspection record and flips the matching `mftproductionplanslave.bFirst1Inspection` so the production line sees the first-piece check has cleared.

**What it does:** Standard `Sp_Calc_*` validate-and-flip — guards `sGuid`/`bInvalid`/`bCheck`, sets `bCheck=1, sStatus=1, sCheckPerson, tCheckDate=NOW()` on `QlyProcessTestMaster`. Joins `mftproductionplanslave` ← `plc_machinedata` ← `QlyProcessTestMaster` (the OEE-side join, distinct from the desktop `Sp_Calc_sPct1` join) to mark `bFirst1Inspection=1`. `iFlag=0` reverses the flags.

**Invocation:** Bound to `gdsmodule.sProcName` on `机长首检登记(OEE)` (sId `12012615914116373127639240`) — OEE管理. Dispatched by `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)`. Auto-invoked from the OEE-terminal save path when the module's auto-audit flag is on (per the header note). Install scripts at `script/标版/30100101/Sp_Calc_sPct3.sql` and `script/标版/optimize/Sp_Calc_sPct3.sql`.
