# `Sp_Check_sPdt` (procedure)

> 成品检验单据保存之前数据校验


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sTableName` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | IN | `iFlag` | `int` |
| 8 | OUT | `sCode` | `int` |
| 9 | OUT | `sReturn` | `varchar(4000)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Check_sPdt`'`._

## Narrative

**Business context:** Post-save validator nominally for 成品检验单据 (per procedure summary), targeting `QlyProductTestMaster`/`QlyProductTestSlave`. Computes 合格/不合格 per slave row from `dNoQualifyQty` vs `iReQty`, rolls sample/test-result fields up to the master, and applies AQL-standard accept-reject totals across each `sAqlstandardId` group — the成品 peer of `Sp_Check_sOdt`.

**What it does:** Reads `sSrcSlaveId` from `QlyProductTestMaster`. Sets `QlyProductTestSlave.sActValue` to `不合格` when `dNoQualifyQty >= iReQty`. Updates `QlyProductTestMaster.dSampleAuxiliaryQty` and `dOutSampleQty` to the max `dSampleQty` across slaves. Then opens a cursor per `sAqlstandardId`, sums `dNoQualifyQty`/`dNoQualifyQty2`, increments `p_iResult` when group totals exceed `p_iAcQty`/`p_iAcQty2`, and writes the final flag back as `QlyProductTestMaster.iTestResult`.

**Invocation:** Status: appears orphaned. No `gdsmodule.sSaveProName`/`sSaveProNameBefore`/`sProcName`/`sDeleteProName` row references it; no form-master `sSqlStr` ref; no other DB routine calls it; xly-src grep finds only `script/标版/30100101/Sp_Check_sPdt.sql` (the install body). The 成品检验 module may instead route through the `Sp_Check_sPdtFJ` 辅检 variant or a tenant-specific override — candidate for maintainer audit.
