# `Sp_WorkOrder_CalcDataPackProductStd` (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 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 包装工单 → 计算 → 成品工序阶段 — first/Before phase of the 包装 (packaging) work-order cost calc. Sibling of `Sp_WorkOrder_CalcDataBsProductStd`; primes the calc-staging tables with finished-product-level (`成品`) figures so the parts-loop and LastStd phases have consistent input. Customer-heaviest of the family (千彩/快马/金宣发/上海亚峰 all ship overrides) — packaging calc-rules diverge widely between plants.

**What it does:** Operates on `mftworkordermaster_Tmp`/`mftworkorderslave_Tmp`/`mftworkordercontrol_tmp`/`mftworkordermaterials_Tmp`/`mftworkorderprocess_tmp` keyed by `sGuid`+`sMakePerson`. Seeds working tables `mftworkordercalc_tmp` (and `_tmpNew`), `mftworkordercontrolcombine_tmp`/`mftworkordercontrolcombinecalc_tmp`/`mftworkordercontrolJson_tmp` (合版 layout), `p_mftworkordercalc_tmp_table[_max]`. Walks every `mftworkorderslave_Tmp` (成品) row to compute its production qty / loss qty / paper area / capacity, primes the per-control-row records so subsequent PartsStd calls read consistent inputs. Stamps `mftworkorderslavemoney_tmp` with the initial money rows.

**Invocation:** Called by `WorkOrderCalcDataPackServiceImpl.doCalcDataPackStdBefore()` as the `Sp_WorkOrder_CalcProduct` slot when running in 包装 mode (it points `Sp_WorkOrder_CalcProduct = Sp_WorkOrder_CalcDataPackProductStd`). Runs once before the per-control PartsStd loop. Install scripts: `script/标版/30100101/Sp_WorkOrder_CalcDataPackProductStd.sql` plus customer overrides in `script/客户/*/`.
