# `Sp_Apply_Flow_OrderChangeNew` (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_OrderChangeNew`'`._

## Narrative

**Business context:** 订单变更单新 — newer workflow-apply data builder for the 销售订单变更 approval flow, replacing `Sp_Apply_Flow_OrderChange`. Adds ten approver tiers + seven scenario flags + 营销一二部 dept-derived branching.

**What it does:** Same `salsalesorderbecomemaster`/`Slave` payload as the original, but tier resolution is widened: `iPosition` 35/6/19/21/14/1/37/11 cover 核价主管/物控经理/技术部长/生产计划经理/发外部门经理/总经理/销售经理/财务经理; one tier (`p_FiveFlow`) is computed dynamically by walking `opsoutsideprocessmaster`→`sisdepart`→`eleemployee` to find the 外购部门 manager for the order's outsource record. Climbs `sisdepart.sParentId` to classify the apply-employee's parent dept as 营销一部 (`17344171700007029955590024910000`) or 营销二部 (`20231120093814840397991462270158`) and emits `p_saledept` 1/2. Sets seven flags `p_iOut1`..`p_iOut7` for downstream: 已下采购, 已下工单, 是否有外购, 是否有发外, 是否有分切工序 (process sId `1691254111216986535514780`), 是否有领料, 是否烟包 (product-classify root `16624527080007919539418229414000`).

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` from `gdsmoduleflow.sApplyProName` (empty in this DB).

Flags: tenant-specific dept-root + process + product-classify GUIDs hardcoded (won't carry to a clone). Form-sId predicates `'192116810113315234963208090'` (工序发外) and `'101801153119616594919790770'` (发外) used to filter `opsoutsideprocessmaster` flavor — also tenant-baked.
