# `Sp_Apply_Flow_MaterialsTest_Proc1` (procedure)

> 来料检验 过程1


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sData` | `longtext` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sInstanceId` | `varchar(100)` |
| 4 | IN | `sTaskParentId` | `varchar(100)` |
| 5 | IN | `sTaskIdNow` | `varchar(100)` |
| 6 | IN | `sComment` | `varchar(100)` |
| 7 | IN | `iPproved` | `varchar(100)` |
| 8 | IN | `sLoginId` | `varchar(100)` |
| 9 | OUT | `sReturn` | `varchar(4000)` |
| 10 | IN | `sBrId` | `varchar(100)` |
| 11 | IN | `sSuId` | `varchar(100)` |
| 12 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 来料检验 → 质量管理单据 → 质量管理 (catalog header: "来料检验 过程1") — companion in-flow update-proc to [`Sp_Apply_Flow_MaterialsTest`](./Sp_Apply_Flow_MaterialsTest.md). Where the latter is the 流程启动前 data-builder, this proc is the in-flow step-handler invoked when an approver sets the `iTypeResult1` disposition route on the IQC unfit-material disposition flow.

**What it does:** Reads `iTypeResult1` from the inbound `sData` JSON (`JSON_EXTRACT(sData, '$.iTypeResult1')`, stripping quotes), then `UPDATE qlycomematerialstestmaster SET iTypeResult1 = p_sTypeResult1, iTestResult = (CASE WHEN p_sTypeResult1=1 THEN 0 ELSE iTestResult END) WHERE sId = sGuid`. The `iTestResult` reset to 0 when `iTypeResult1=1` reflects the rule: choosing disposition #1 (typically 让步接收) clears the pass/fail flag for downstream reposting. Returns the standard `sCode/sReturn` workflow contract.

**Invocation:** Dispatched dynamically by the workflow engine on an in-flow step. Java side runs `doProByNameFlow(...)` with the proc name pulled from the workflow step's calc-proc configuration. `gdsmoduleflow` is empty in this database — workflow configs are tenant-provisioned per deployment. No direct callers in DB routines or xly-src grep.

Flags: variable declared `varchar(100)` then assigned to an integer column — implicit cast.
