# `Sp_WorkOrder_CalcDataBsPartsStd` (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_tDeliverDate` | `datetime` |
| 10 | IN | `p_sControlId` | `varchar(100)` |
| 11 | IN | `sAllGuid` | `varchar(4000)` |
| 12 | IN | `bSample` | `int` |
| 13 | IN | `dSumPQtyS` | `decimal(18,6)` |
| 14 | IN | `p_iPage` | `int` |
| 15 | IN | `p_bPublicPlate` | `int` |
| 16 | IN | `p_sCombinedMemo` | `longtext` |
| 17 | OUT | `sCode` | `int` |
| 18 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 商务工单 → 计算 → 部件工序阶段 (商务工单计算部件工序部分) — per-control-row parts/process calc for the 商务 (business) work-order branch. Sibling of `Sp_WorkOrder_CalcDataPackPartsStd`; the orchestrator loops one call per `mftworkordercontrol_tmp` row (each 部件/拼版) so each parts grouping is costed independently before the LastStd phase rolls them up.

**What it does:** Operates on `T_mftworkordercalc_tmp` plus the `mftworkordermaster_Tmp` / `mftworkordercontrol_tmp` / `mftworkordermaterials_tmp` / `mftworkorderprocess_tmp` staging keyed by `sGuid`+`sMakePerson`. For the supplied `p_sControlId`, computes per-process input/output quantities, loss qty, capacity hours, process money, materials qty — handling 公版 (`p_bPublicPlate`)/合版 (`p_sCombinedMemo`)/sample (`bSample`) variants. `INSERT INTO T_mftworkordercalc_tmp` accumulates calc rows for the LastStd phase to consume. Caller is responsible for looping; this proc handles a single control row.

**Invocation:** Called by `WorkOrderCalcDataPackServiceImpl.doCalcDataPackStd()` as the `Sp_WorkOrder_CalcPartsStd` slot when running in 商务 mode (it points `Sp_WorkOrder_CalcPartsStd = Sp_WorkOrder_CalcDataBsPartsStd`). The Java service builds the call string via `getCallPart(…)` and runs it once per control-table row. Install script: `script/标版/30100101/Sp_WorkOrder_CalcDataBsPartsStd.sql`.
