# `Sp_Quotation_CalcDataPack` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(100)` |
| 2 | IN | `bChangeRate` | `int` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |
| 6 | OUT | `sCode` | `int` |
| 7 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 销售管理 → 报价&估计管理 → 01/04【新增】新报价单 (gdsmodule sId `101251240115016076506222050`) — top-level quote-cost calculator for the packaging-product (包装) family on the "new quote" form. Orchestrates the pack-quote pipeline that distributes work across the parts/last-process/std sub-routines and records progress per slave.

**What it does:** From `quoquotationmaster_tmp` + slave/control/materials/process/control-combine `_tmp` snapshots, fills two working temp tables (`p_controlTable`, `p_controlCombineTable`) and reports lifecycle status to `quoquotation_progress` (one row per slave). For each control row it dispatches to one of three sub-routines depending on context: `CALL Sp_Quotation__CalcDataPackLastStd(...)` for the final/last-process control, `CALL Sp_Quotation__CalcDataPackPartsStd(...)` for parts roll-up, `CALL Sp_Quotation_CalcDataPackProductStd(...)` for the product-level pass, and `CALL Sp_Quotation_CalcDataStd(...)` as fallback. Localizes outputs via `Sp_Sis_GetConst` + `Sp_System_ReplaceField` and writes back to `quoquotationcontrol_tmp` / `quoquotationControlCombine_Tmp`.

**Invocation:** Two invocation paths converge here:
1. Bound as `gdsmodule.sCalcProName='Sp_Quotation_CalcDataPack'` for the 01/04【新增】新报价单 module — the standard single-quantity save fires this from the form-level calc dispatcher.
2. Multi-quantity quote flow: `QuoquotationController.addQuotationsheetMany()` (xly-src `xlyEntry/web/businessweb/QuoquotationController.java`) calls `this.manyQuoService.addQuotationsheetManyThread(params, userInfo, "Sp_Quotation_CalcDataPack")` — the proc name is hard-coded as the third arg and `ManyQuoServiceImpl.addQuotationsheetManyThread()` spawns a thread per quantity tier each calling this proc.

Also enumerated as `CaclProNameEnum.SP_QUOTATION_PACKSTD`. xly-src ships the install body at `script/标版/30100101/Sp_Quotation_CalcDataPack.sql` and a customer override at `script/客户/上海亚峰/报价单计算/Sp_Quotation_CalcDataPack.sql` — verify which is deployed.
