# `Sp_WorkOrder_CalcDataBookStd` (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_CalcDataBookStd`'`._

## Narrative

**Business context:** 生产管理 / 生产工单 → 计算 (书刊工单) — full-bill cost/quantity calculation for 书刊 (book/magazine) work-orders. One of the four model-specific siblings of `Sp_WorkOrder_CalcDataStd`: `Pack` (包装), `Book` (书刊), `Set` (套装), `Flex` (柔印), with `Std` as the default fallback. The calc rewrites the calc-staging snapshot tables so the user can preview material/process figures before saving.

**What it does:** Operates entirely 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`), derives slave/customer/product context, then walks every control row (printing-plate/parts) and process row to compute paper area, run-counts, loss qty, capacity hours, and money figures specific to the book-binding flow (signatures, gathering, binding). Calls `Sp_Sis_GetConst` for error messages and `Sp_System_ReplaceField` for formula substitution.

**Invocation:** Dispatched by `Sp_Calc_sBgd` (the 生产工单 audit/calc entry) when the work-order's `sFormId='101251240115016042931766970'` (书刊工单). Also enumerated in `CaclProNameEnum.SP_WORKORDER_CALCDATABOOKSTD` for direct Java invocation via `WorkOrderCalcDataPackService`. Install script: `script/标版/30100101/Sp_WorkOrder_CalcDataBookStd.sql`.
