# `Sp_Apply_Flow_ProductTest` (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 | `sSrcNo` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | OUT | `sTableParams` | `longtext` |
| 6 | OUT | `sSrcReportData` | `longtext` |
| 7 | OUT | `sTableParamsValue` | `longtext` |
| 8 | OUT | `sReturn` | `varchar(4000)` |
| 9 | IN | `sBrId` | `varchar(100)` |
| 10 | IN | `sSuId` | `varchar(100)` |
| 11 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 成品发外检验 — workflow-apply data builder for the 发外成品检验 approval flow on `QlyProductTestMaster`. Sibling of `Sp_Apply_Flow_ProcessTest` but for finished-product (not process-step) external inspection.

**What it does:** Reads `QlyProductTestMaster` for `sGuid` joined to `eleproduct`/`elesupply`/`elecustomer`. Payload carries `sBillNo`, `sWorkOrderNo`, `sCheckMemo` (= `产品名➜客户名➜供应商名`), `dNoQualifyQty`, `iTypeResult`/`iTypeResult1`. Resolves five tiers from `eleemployee.iPosition` (17=SQE, 14=外协经理, 18=品质经理, 8 OR 21=生产经理/生产部长); 外协人员 (`p_TwoFlow`) is the source-outsource 制单人 via `opsoutsideprocessmaster.sId=QlyProductTestMaster.sSrcId`. **Early exit:** if `iTestResult=0` (already qualifies) sets `sCode=2` and LEAVE top without emitting the payload — workflow handles this as a manual-close case.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` from `gdsmoduleflow.sApplyProName` (empty in this DB). Companion procs `_Proc1`/`_Proc2` write back `iTypeResult1`/`iTypeResult` from in-flow user input.
