# `Sp_productionMainPlan_BtnEventSingleOutgoing` (procedure)

> @author:钱豹
	@date:20210711 封存
							@describe: 主生产计划，"整单发外"调用，主要功能：
							1、更新工单，装配单 整单发外标记
							2、更新主生产计划 状态，发外标记
							3、冻结机台计划中本工单所有已上报记录;删除机台计划所有没有上报的数据


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 生产管理 / 主计划 → 整单发外 — planner-grid "send entire work-order out for outsourced processing" button. Marks the work-order and its semi-good match bill as outsourced, transitions the plan row to `sState='5'` (outsourced), freezes already-reported slave rows and discards unreported ones from the machine schedule. Header comment by 钱豹 (2021-07-11 sealed) lists the same three responsibilities.

**What it does:** Parses `$.params[*].value[*].sId`. For each plan id: `UPDATE mftworkordermaster SET bBillOutside=1` for the underlying `sWorkOrderId`; `UPDATE sgdsemigoodsmatchbillmaster SET bBillOutside=1` for the same id; `UPDATE mftproductionplan SET sState='5', bBillOutside=1`. Then on `mftproductionplanslave` keyed by `sWorkOrderId`: rows with `dProductionReportQty > 0` are frozen (`bFrozen=1`); rows with no production reported are deleted.

**Invocation:** Standard `Sp_<Module>_BtnEvent*` slot — dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` when the 主计划 grid's 整单发外 button names this procedure. xly-src ships `script/标版/30100101/schedule/Sp_productionMainPlan_BtnEventSingleOutgoing.sql`. Inverse: `Sp_productionMainPlan_BtnEventSingleOutgoingFHCP` (and the workorder-keyed undo `Sp_productionMainPlan_BtnEventworkorder`).
