# `Sp_WorkOrder_CalcDataPackPartsStd` (procedure)


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(100)` |
| 2 | IN | `sLoginId` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | IN | `p_sFormId` | `varchar(100)` |
| 6 | IN | `p_sSlaveGuid` | `varchar(100)` |
| 7 | IN | `p_sCustomerId` | `varchar(100)` |
| 8 | IN | `p_sProductId` | `varchar(100)` |
| 9 | IN | `p_tDeliverDate` | `datetime` |
| 10 | IN | `p_sControlId` | `varchar(100)` |
| 11 | IN | `sAllGuid` | `varchar(4000)` |
| 12 | IN | `bSample` | `int` |
| 13 | IN | `dSumPQtyS` | `decimal(18,6)` |
| 14 | IN | `p_iPage` | `int` |
| 15 | IN | `p_bPublicPlate` | `int` |
| 16 | IN | `p_sCombinedMemo` | `longtext` |
| 17 | OUT | `sCode` | `int` |
| 18 | OUT | `sReturn` | `varchar(5000)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_WorkOrder_CalcDataPackPartsStd`'`._

## Narrative

**Business context:** 包装工单 → 计算 → 部件工序阶段 — per-control-row dispatch shim for the 包装 (packaging) parts/process calc. Sibling of `Sp_WorkOrder_CalcDataBsPartsStd`; the orchestrator loops one call per `mftworkordercontrol_tmp` row. This thin wrapper inspects the control-row hierarchy and decides whether to recurse from the innermost split-children outward or kick off straight from the outermost control row.

**What it does:** Resolves the outermost `sControlParentId` for `p_sControlId` from `mftworkordercontrol_tmp` (`sParentId=sGuid`, scoped by 品牌/分公司), then builds temp `p_calc_MftWorkOrderControl_split` listing every part under that outermost control. If no rows have `bSplit=1` and the control isn't innermost (`sChildren=0`), leaves; otherwise dispatches one or more calls to `Sp_WorkOrder_CalcDataPackPartsStd_child` with the split flag — once for the "from-inside-out" walk and once more for split children. All real computation happens in `_child`.

**Invocation:** Called by `WorkOrderCalcDataPackServiceImpl.doCalcDataPackStd()` as the `Sp_WorkOrder_CalcPartsStd` slot when running in 包装 mode (it points `Sp_WorkOrder_CalcPartsStd = Sp_WorkOrder_CalcDataPackPartsStd`). The Java service builds the call string via `getCallPart(…)` and runs it once per control-table row. Install scripts: `script/标版/30100101/Sp_WorkOrder_CalcDataPackPartsStd.sql` plus customer overrides in `script/客户/*/`.
