# `Sp_Order_Scrap_Confirm_Flow` (procedure)

> 流程启动前调用


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sFormGuid` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sSrcNo` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | OUT | `sTableParams` | `longtext` |
| 6 | OUT | `sSrcReportData` | `longtext` |
| 7 | OUT | `sTableParamsValue` | `longtext` |
| 8 | OUT | `sReturn` | `varchar(4000)` |
| 9 | IN | `sBrId` | `varchar(100)` |
| 10 | IN | `sSuId` | `varchar(100)` |
| 11 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 生产管理 / 工单废品确认 — pre-flow gate for the OrderScrapConfirm (订单废品确认) approval workflow. Stamps the 废品审核 marker on `mftworkordermaster`, hard-deletes any stale draft approval rows for the order, and computes the runtime 会签 participant list (车间班组 foreman + 外发废 supervisor) handed to the workflow engine as routing parameters.

**What it does:** Refuses with `sCode=-1` when `sGuid=''` or when any 核检废 detail (`mftproductproductionplanbxfpdetail` joined via `mftproductproductionplanbxfpmaster`) is unaudited. Sets `bBfCheck=1, tBfCheckDate=NOW(), sBfCheckPerson=sLoginId` on `mftworkordermaster` for `sGuid`. Deletes existing `biz_flow` rows (and the matching `biz_todo_item` instances) of `type='OrderScrapConfirm'` for any work-order with `bBfCheck=0 AND tBfCheckDate IS NOT NULL` to clear stale runs. Builds `p_OneFlow` by GROUP_CONCAT(`eleemployee.sEmployeeName`) for the foremen of every team that owns a 核检废 detail on this order, and appends the 外发废 supervisor (`sisdepart`-resolved) when `mftproductproductionplanbxfpdetailsum.dWastesQty6 > 0`. The list flows out via the OUT params (`sTableParamsValue`) for the flow engine.

**Invocation:** Status: appears orphaned by the standard channels (no form-master / gdsmodule hook / other-routine caller / xly-src grep). The body COMMENT `流程启动前调用` plus the JSON-style OUT params strongly indicate this is wired as the pre-flow hook of an `OrderScrapConfirm` workflow definition (typically `gdsmoduleflow.sApplyProName` or a flow-instance binding read by `CheckExamineFlowDataServiceImpl`) — verify the runtime workflow row references this proc.
