# `Sp_Apply_Flow_mftMaterialsReturn` (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_mftMaterialsReturn`'`._

## Narrative

**Business context:** 材料测试反馈 / 研发反馈 (catalog header: "流程启动前调用-材料测试"; backing table `mftmaterialstest` — supplier-material trial-run feedback record). Per-form workflow-apply data builder for the supplier-feedback approval flow. Naming is confusing: "MaterialsReturn" in the proc name refers to *feedback return to supplier*, not material physical return, mirroring the convention in [`Sp_Apply_Flow_MaterialsReturn`](./Sp_Apply_Flow_MaterialsReturn.md).

**What it does:** Resolves one approver tier (供应链部长, `iPosition=5`) into `p_OneFlow`. Emits `sTableParams` (反馈单号/供应商/测试物料/车间主管反馈/技术工程反馈/技术部长反馈/测试结果/备注信息) and `sTableParamsValue` (JSON joining `mftmaterialstest`/`elematerials` for `sBillNo`/`sMaterialsName`/`sSupplyName`/三段 `sFeedBack{1,2,3}Memo`/`sMemo` + `sSucceed` translated via CASE on `iSucceed` (1→通过, 2→未通过, else→empty) + `OneFlow`).

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` where `sApplyProName` is read from `gdsmoduleflow.sApplyProName` on the 材料测试 workflow config row. `gdsmoduleflow` is empty in this database — workflow configs are tenant-provisioned per deployment.
