# `Sp_Apply_Flow_Yzfy` (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_Yzfy`'`._

## Narrative

**Business context:** 费用预支单 — workflow-apply data builder for the cost-advance approval flow on `advanceCostCheckMaster`. Builds a seven-tier base roster plus two management-control overrides (人力资源 + 总经办) gated on the expense-detail's `sControlDepartId`.

**What it does:** Reads master `advanceCostCheckMaster` for `sGuid` and resolves seven base tiers — `p_OneFlow` (申请人部门负责人), `p_TwoFlow` (上级部门领导), `p_ThreeFlow` (税务费用核算专员 via `sisposition.sName`), `p_FourFlow` (财务负责人 `iPosition=11`), `p_FiveFlow` (副董执行董事 `iPosition=38`), `p_SixFlow` (国内副总 `iPosition=34`), `p_SevenFlow` (总经理 `iPosition=1`). The same 李国哲/烟包 swap pattern as `Sp_Apply_Flow_Ystz` redirects `p_TwoFlow` to dept-head sId `17344171700007029955590024910000` for non-烟包. Then joins `advancecostcheckslave` to `descriptionOfFeesMaster` and detects two control departments: `sControlDepartId='20231120093814625300245934269895'` (人力资源 → sets `p_iAdjustmentType=1`, populates `p_ControlFlow`) and `'20231120093814302718413294429806'` (总经办 → sets `p_iAdjustmentType1=1`, populates `p_ControlFlow1`). `p_iAdjustType=1` if either; if 总经办-only, `p_iAdjustmentType=2`. Final JSON includes 8 tier fields plus the two control flow slots, three adjust-type flags, and `iCigPack`.

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

Flags: hardcodes 4 tenant-specific GUIDs — 事业部 dept (`17344171700007029955590024910000`), 人力资源 control dept (`20231120093814625300245934269895`), 总经办 control dept (`20231120093814302718413294429806`). 财务经理 (`p_FourFlow`) reads `iPosition=11` rather than the commented-out `sisposition.sName='财务经理'` query — `iPosition` semantics must match across employee data.
