# `Sp_WorkOrder_CalcDataStd` (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_CalcDataStd`'`._

## Narrative

**Business context:** 生产管理 / 生产工单 → 计算 (默认/通用工单) — full-bill cost/quantity calculation for the default (general) work-order model. Default fallback in the `Pack`/`Book`/`Set`/`Flex` family — `Sp_Calc_sBgd` dispatches to one of the three model-specific siblings by `sFormId`, falling through to this proc when no specific match. The root entry the rest of the family was forked from.

**What it does:** Operates entirely on the `mftworkordermaster_Tmp` / `mftworkorderslave_Tmp` / `mftworkordercontrol_tmp` / `mftworkordermaterials_tmp` / `mftworkorderprocess_tmp` staging snapshot 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 default formula set. Calls `Sp_Sis_GetConst` and `Sp_System_ReplaceField`. Also referenced from `Sp_Manufacture_InsertWorkOrder` (work-order insert path) for the initial calc.

**Invocation:** Dispatched by `Sp_Calc_sBgd` as the `Else` branch (any work-order whose `sFormId` isn't 包装/书刊/套装). Default constant `typeNameDefalut = "Sp_WorkOrder_CalcDataStd"` in `CaclProNameEnum` — `getNameByKey()` returns this when no key matches. Install scripts: `script/标版/30100101/Sp_WorkOrder_CalcDataStd.sql` plus customer overrides in `script/客户/无锡中江/`, `script/客户/福雅/`.
