# `Sp_Apply_Flow_CLReject` (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_CLReject`'`._

## Narrative

**Business context:** 材料报废 (Material Reject/Scrap) workflow-apply data builder — header says 流程启动前调用-材料报废. One of the per-form `Sp_Apply_Flow_<Form>` procs the workflow engine invokes before starting an approval chain on `mitproductionmaterialsmaster` (单据类型: 材料报废 / 返工领料 / etc).

**What it does:** Resolves four approver tiers from `eleemployee` by `iPosition` — 财务经理 (11), 总经理 (1), 品管 (18), 国内事业副总 (34). Builds `p_sMaterialsName` by aggregating `mitproductionmaterialsslave` joined to `elematerials` into a `物料名称➜规格➜数量➜单位` summary. Emits `sTableParams` = label-JSON, `sTableParamsValue` = value-JSON of `sBillNo`/`sBussinessType`/`sMaterialsMemo`/`sMemo` plus a derived `iBusinessType` enum (1=材料报废, 2=返工领料, 3=other) and the four approver lists (`OneFlow`/`TwoFlow`/`ThreeFlow`/`TenFlow`).

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