# `Sp_Apply_Flow_ProcessChange` (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_ProcessChange`'`._

## Narrative

**Business context:** 工艺变更单 — workflow-apply data builder for the 工艺变更 approval flow on `mftprocesschangemaster`. Builds the ten-tier approver roster and the variance summary that the BACK approval UI surfaces before routing.

**What it does:** Reads `mftprocesschangemaster` for `sGuid`; payload exposes `sBeforeMemo`/`sAfterMemo` change diff, `iChangeType` mapped to display strings (材料变更/工艺变更/文件内容变更/暂停/启动) plus `iFileType` (保留-新增版本/删除-原版本替换), `dPoorMoney` cost variance, and `iOrderChange` flag. Resolves ten approver tiers: `iPosition` 35/19/4/6/3/8/37 are 核价员/技术经理/客服经理/物控经理/营销部长/生产部长/营销经理; 客服 (`p_TwoFlow`) is the order-sales 制单人 chained via `salsalesordermaster`→`mftworkorderslave`→`mftprocesschangemaster`; 车间主任 (`p_ThreeFlow`) is the dept-leader of the change-master 制单人 via `sisdepart.sEmployeeId`; 工艺 (`p_FourFlow`) is the work-order 制单人. Sets four scenario flags: 是否车间提出 (`iProposeType`), 变更类型 (`iChangeType`), `iOut2`=YFGD prefix in `sWorkOrderNo`, 材料是否下过订单 via `purpurchaseorderdetail`→`mftworkordermaterials` join, 是否烟包 via product-classify root `16624527080007919539418229414000`.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` from `gdsmoduleflow.sApplyProName` (empty in this DB). Companion procs `_Proc1`/`_Proc2` write back `dPoorMoney`/`iOrderChange` from in-flow user input.
