# `Sp_Apply_Flow_MaterialsApply` (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_MaterialsApply`'`._

## Narrative

**Business context:** 补料申请 → 现场物料管理 → 生产执行 (catalog header: "流程启动前调用-补料申请"; module sId `12012615914116370198739420`, supplementary-material request kicked off when production needs additional material mid-run). Per-form workflow-apply data builder backing the 补料申请单据 (form sId `12012615914116395420094430`, tbName `mitproductionapplymaster`).

**What it does:** Resolves four approver tiers from `eleemployee`: 品质部 / 技术部 / 机修部 (`iPosition` 18 / 19 / 29) and 车间主任 (制单人的部门负责人 — chain `mitproductionapplymaster.sMakePerson` → `eleemployee.sDepartId` → `sisdepart.sEmployeeId` → `eleemployee.sEmployeeName`, into `p_FourFlow`). Aggregates `mitproductionapplyslave` rows into `p_sMaterialsMemo` as `'材料名称：{sMaterialsName}➜补料数量：{dAuxiliaryQty}'` joined by newline. Emits `sTableParams` (column-label JSON: 补料单号/补料信息/参与部门/备注) and `sTableParamsValue` (JSON of master values + `iFlowTrend` + the four approver name lists `OneFlow`/`TwoFlow`/`ThreeFlow`/`FourFlow`).

**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.
