# `Sp_WorkOrder_CalcDataPackPartsStd_child` (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 | IN | `p_bSplit` | `int` |
| 18 | OUT | `sCode` | `int` |
| 19 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 包装工单 → 计算 → 部件工序阶段 (内部递归) — heavy-lifting child of `Sp_WorkOrder_CalcDataPackPartsStd`. Takes the same args plus `p_bSplit` and does the actual per-part calc against the staging tables. The dispatcher (`PartsStd`) decides which control rows need calc and recurses through this proc for each, walking from innermost children outward.

**What it does:** Builds heavy working tables — `p_calc_MftWorkOrderControl` (full control hierarchy), `_all` (incl. parents), `_first_cal`, `_next` (next-process), `p_mftworkordercalc_tmp_table`, `p_mftworkordercontrolcombine_tmp`/`_json` (合版 layout) — then for the supplied `p_sControlId` computes per-process input/output qty, loss qty, capacity hours, process money, materials qty under packaging-specific formulas (合版/公版/拆切/sample). Accumulates results into `mftworkorderslavemoney_tmp` for the LastStd phase to roll up. The recursion handles nested control hierarchies (one part split into sub-parts split into sheets, etc.).

**Invocation:** Called by `Sp_WorkOrder_CalcDataPackPartsStd` (the same-named dispatcher without `_child`); never invoked directly from Java. The dispatcher passes `p_bSplit=0` for the innermost walk and `p_bSplit=1` for split-child walks. No xly-src install script present (DB-only definition) — the dispatcher is in `script/标版/30100101/Sp_WorkOrder_CalcDataPackPartsStd.sql`; the `_child` body lives in the same family of customer-override scripts.
