# `Sp_WorkOrder_CalcDataFlex` (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_CalcDataFlex`'`._

## Narrative

**Business context:** 生产管理 / 生产工单 → 计算 (柔印工单) — full-bill cost/quantity calculation for 柔印 (flexographic-print) work-orders. One of the four model-specific siblings of `Sp_WorkOrder_CalcDataStd`: `Pack` (包装), `Book` (书刊), `Set` (套装), `Flex` (柔印). Largest of the family by code size — the flexo flow has additional paper-roll/web handling and per-station ink-laydown logic.

**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 flexo formula set. Calls `Sp_Sis_GetConst` for error messages and `Sp_System_ReplaceField` for formula substitution.

**Invocation:** Enumerated in `CaclProNameEnum.SP_WORKORDER_CALCDATAFLEX` for direct Java invocation. Dispatched by `Sp_Calc_sBgd` (生产工单 audit/calc entry) as the fallback/柔印 branch alongside `Sp_WorkOrder_CalcDataStd`. Install script: `script/标版/30100101/Sp_WorkOrder_CalcDataFlex.sql`.
