# `Sp_Apply_Flow_MaterialsApplyLL` (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_MaterialsApplyLL`'`._

## Narrative

**Business context:** 领料申请 → 现场物料管理 → 生产执行 (catalog header: "流程启动前调用-领料申请"; module sId `101251240115016056026513090`, the material-issue request submitted before warehouse releases stock). Per-form workflow-apply data builder backing the 领料申请单据 (form sId `101251240115016056026129010`, tbName `mitproductionapplymaster`).

**What it does:** Resolves the领料人员's 二级部门负责人 list as the single approver tier (`p_OneFlow`) — explicitly *not* the制单人, because the same person may submit on behalf of multiple departments (e.g., 机修 and 技术). Resolution chain: `mitproductionapplymaster.sEmployeeId` → `eleemployee.sDepartId` → `sisdepart.sEmployeeId` → `eleemployee.sEmployeeName`. Pulls 使用部门 from `mitproductionapplymaster.sUseDeptId` → `sisdepart.sName` and 设备名称 from `mitproductionapplymaster.sMachineId` → `elemachine.sMachineName`. Aggregates `mitproductionapplyslave` rows into `p_sMaterialsMemo` as `'材料名称：{sMaterialsName}➜领料申请数量：{dAuxiliaryQty}'` joined by newline. Emits `sTableParams` (column-label JSON: 领料申请单号/领料信息/使用部门/设备名称/备注) and `sTableParamsValue` (JSON of master values + `iSource` + `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. The proc-header comment explicitly notes: "领料申请：除工单领料外，其它领料增加一个审核节点审批通过后领料 (目前有领料出现错误的问题)".
