# `Sp_Apply_Flow_Supply` (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_Supply`'`._

## Narrative

**Business context:** 供应商准入 (流程启动前调用-供应商准入) — workflow-apply data builder for the supplier-onboarding approval flow on `elesupply`. Builds an eleven-tier roster, supplier-classify-driven branch, payment-term flag, dept flag (供应链管理), and 烟包 indicator.

**What it does:** Resolves tiers from `eleemployee.iPosition`: 6=物控经理, 5=采购部长, 8=技术部长, 9=生产部长, 11=财务经理, 1=总经理, 38=副董执行董事, 34=国内副总, 39=董事长, 40=供应链经理, 41=产品设计与开发. Reads `sParentId` (supplier classify) and `sGetPayId`. Computes `p_iFlow1=1` when payment is one of four prepaid/票到/货到/预付款 GUIDs (`1573542941...`, `1682658739...`, `2023113014...`, `1701870942...`). Computes `p_iFlow` by classify: 1=纸张/辅料/模具 (`1698744948...`/`1701485801...`/`1701485812...`), 2=加工商/设备配件/服务商 (`1698744954...`/`1698744966...`/`1698744980...`), 3=物流 (else). Checks applicant dept against `'17344173190001090119214960551400'` (供应链 dept root); `p_dept=1` if match. Emits master `sSupplyNo`, `sSupplyName`, `sissupplyclassify.sName`, `sMemo`, `iCigPack` (read directly from master `A.iCigPack`).

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

Flag: hardcodes 12 tenant-specific GUIDs (4 payment terms + 6 supplier classifies + 供应链 dept root + 烟包 classify) — supplier classifications need re-mapping if cloned to a different tenant.
