# `Sp_Quotation__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_sControlId` | `varchar(100)` |
| 10 | IN | `sAllGuid` | `longtext` |
| 11 | IN | `dSumPQtyS` | `decimal(18,6)` |
| 12 | IN | `p_NetMoney` | `int` |
| 13 | IN | `p_iPage` | `double` |
| 14 | IN | `p_sCombinedMemo` | `varchar(1000)` |
| 15 | OUT | `sCode` | `int` |
| 16 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 销售管理 → 报价&估计管理 → 新报价单 — parts-roll-up stage of the packaging-product (包装) quote-cost engine. Sits between `Sp_Quotation__CalcDataPackLastStd` (per-control / last-process math) and the master-summary phase in `Sp_Quotation_CalcDataPack`: aggregates per-`sControlId` parts quantities (`dPartsQty`), per-product distribution (`p_iPage` running counter, `p_sCombinedMemo` accumulator) and applies `sAllGuid` (the CSV of slave ids participating in the combined-control set) to drive the multi-parts arithmetic.

**What it does:** For the given `p_sControlId` row of `QuoQuotationControl_Tmp`, sums materials & process input/output quantities across the parts identified by `sAllGuid`, divides totals by `dSumPQtyS` to derive per-unit parts share, and writes results back into `QuoQuotationControl_Tmp`/`QuoQuotationMaterials_Tmp`/`QuoQuotationProcess_Tmp` (same temp set the front-end will render). Net money is propagated via `p_NetMoney`, page index via `p_iPage`. Localises error/result strings via `Sp_Sis_GetConst` and `Sp_System_ReplaceField`.

**Invocation:** Called by `Sp_Quotation_CalcDataPack` (`CALL Sp_Quotation__CalcDataPackPartsStd(...)`) inside the packaging-quote calculation chain. The outer entry point — `Sp_Quotation_CalcDataPack` — is invoked from `ManyQuoServiceImpl.addQuotationsheetManyThread(params, userInfo, "Sp_Quotation_CalcDataPack")` (called by `QuoquotationController` for the multi-quantity quote flow) or via `gdsmodule.sCalcProName='Sp_Quotation_CalcDataPack'` for the standard single-quantity save path. xly-src ships a 上海亚峰 customer-override at `script/客户/上海亚峰/报价单计算/Sp_Quotation__CalcDataPackPartsStd.sql` — verify which body is deployed.
