# `Sp_Apply_Flow_salesmaterials` (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_salesmaterials`'`._

## Narrative

**Business context:** 研发申请材料测试 (流程启动前调用-研发申请材料测试) — workflow-apply data builder for the R&D material-test application approval flow on `salsalesordermaster`. Builds a six-tier roster with applicant-dept-driven branch and applicant-dept-equals-客服经理 short-circuit.

**What it does:** Reads `sMakePerson` and `sOrderType` from master (recoded as `p_iOrderType`: 5→1, 4→2, else 3). Resolves `p_FourFlow` (二级部门负责人) by climbing applicant's dept once via `sisdepart.sId=eleemployee.sDepartId` → `sisdepart.sEmployeeId`. Resolves tiers from `eleemployee.iPosition`: 6=物控, 9=技术部, 8=生产部, 4=客服经理, 5=供应链部长. Sets `p_iOut=1` when `p_FourFlow=p_FiveFlow` (applicant's二级部门负责人 is also the 客服经理, collapses parallel approval). Emits per-line memo CONCAT-ing `研发材料➜研发数量➜供应商➜试制原因及要求` from `salsalesorderslave`. Renders `sOrderType` into 打样/印前/设计/拷文件/新品测试 labels and `iDemand` into 内部需求/外部需求.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` from `gdsmoduleflow.sApplyProName` (empty in this DB — workflow configs tenant-provisioned per deployment).
