# `Sp_WorkOrder_CalcDataSetStd` (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_WorkOrder_CalcDataSetStd`'`._

## Narrative

**Business context:** 生产管理 / 生产工单 → 计算 (套装工单) — full-bill cost/quantity calculation for 套装 (set/kit) work-orders. One of the four model-specific siblings of `Sp_WorkOrder_CalcDataStd`: `Pack` (包装), `Book` (书刊), `Set` (套装), `Flex` (柔印). Drives the calc when a single work-order bundles multiple finished products as a kit.

**What it does:** Operates on the `mftworkordermaster_Tmp` / `mftworkorderslave_Tmp` / `mftworkordercontrol_tmp` / `mftworkordermaterials_tmp` / `mftworkorderprocess_tmp` staging set keyed by `sGuid`+`sMakePerson`. Reads system constants (`CbxCorrugateWidth`/`CbxCorrugateLength`/`NetCorrugateLengthSubtract`/`NetCorrugateWidthSubtract` from `SysSystemSettings`), iterates every slave (成品) and control (部件/印刷) row, computes paper area, run-counts, loss qty, capacity hours, and process money under the kit-bundling formula set. Calls `Sp_Sis_GetConst` for error messages and `Sp_System_ReplaceField` for formula substitution.

**Invocation:** Dispatched by `Sp_Calc_sBgd` (生产工单 audit/calc entry) when the work-order's `sFormId='101251240115016087802299360'` (套装工单). Also enumerated in `CaclProNameEnum.SP_WORKORDER_CALCDATASETSTD` for direct Java invocation. Install script: `script/标版/30100101/Sp_WorkOrder_CalcDataSetStd.sql`.
