# `Sp_QlyComeMaterialsJudge` (procedure) > 材料检验自动判断抽检及合格 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sFormGuid` | `varchar(100)` | | 2 | IN | `sGuid` | `varchar(100)` | | 3 | IN | `sTableName` | `varchar(100)` | | 4 | IN | `sLoginId` | `varchar(100)` | | 5 | OUT | `sReturn` | `varchar(4000)` | | 6 | IN | `sBrId` | `varchar(100)` | | 7 | IN | `sSuId` | `varchar(100)` | | 8 | OUT | `sCode` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_QlyComeMaterialsJudge`'`._ ## Narrative **Business context:** 质量管理 / 来料检验 — auto-evaluates a 材料检验 record (`QlyComeMaterialsTestMaster` / `QlyComeMaterialsTestSlave`) against the AQL sampling standard: pulls the standard's sample/accept/reject thresholds from `EleTestStandardItem`, marks each inspection line 合格/不合格, and rolls up to a master-level `iTestResult` pass/fail. Signature (`sFormGuid, sGuid, sTableName, sLoginId, sReturn, sBrId, sSuId, sCode`) matches the standard button-action contract. **What it does:** Counts `QlyComeMaterialsTestSlave` rows where `sAqlstandardId` joins `EleTestStandardItem`; if any: (1) `UPDATE` the slave's `dSampleQty / iAcQty / iReQty` from the standard band where `dAuxiliaryQty BETWEEN iQuantityFrom AND iQuantityTo`; (2) `UPDATE` each slave's `sActValue = CASE WHEN dNoQualifyQty >= iReQty THEN '不合格' ELSE '合格' END`; (3) sets master `dSampleQty` to the max slave `dSampleQty`. Then opens a cursor over `(sAqlstandardId, iAcQty, iAcQty2)` summing `dNoQualifyQty`/`dNoQualifyQty2` per standard and flagging master `iTestResult = (Case WHEN p_iResult > 0 THEN 1 ELSE 0 END)`. Finally fills `sTestPersonId` from `eleemployee` and `CALL Sp_afterSave_sCmt` to chain the standard after-save hook for the 来料检验 form code `sCmt`. **Invocation:** Status: appears orphaned. No caller found in any channel (form-master, gdsmodule sSaveProName/sCalcProName, other routines, xly-src grep across all extensions). The signature and the `Sp_afterSave_sCmt` call strongly suggest this is meant to be the calc/judge hook for the 来料检验 form (`sCmt`) — likely invoked dynamically by name from a Java button-action handler not present in xly-src, or bound through a tenant-specific config column; candidate for maintainer audit.