# `Sp_Apply_Flow_productpd` (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_productpd`'`._

## Narrative

**Business context:** 成品盘点 — workflow-apply data builder for the 成品盘点 approval flow on `pitproductcheckmaster`. Builds the two-tier approver roster (仓库组长 + 成本会计) and the count-sheet header for the BACK approval UI.

**What it does:** Reads `pitproductcheckmaster` joined to `siswarehouse` for `sGuid`. Payload exposes `sBillNo`, `sWareHouseName`, `sEmployeeName` (= 制单人), `sCreateDate` formatted `%Y-%m-%d`, `sMemo`. Resolves 仓库组长 (`p_OneFlow`) by `eleemployee.iPosition=32 AND (sEmployeeNo='00034' OR iPosition=7)` and 成本会计 (`p_TwoFlow`) by `sEmployeeNo='06376' OR iPosition=33`.

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

Flag: 仓库组长 predicate `iPosition=32 AND (sEmployeeNo='00034' OR iPosition=7)` is malformed — the second `iPosition=7` branch is unreachable since the outer `AND iPosition=32` already filtered to 32 (same bug as `Sp_Apply_Flow_materialspd`). Hardcoded 工号 `'00034'`/`'06376'` are tenant-baked.
