# `Sp_productionMainPlan_BtnEventSingleOutgoingFHCP` (procedure)


- **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_BtnEventSingleOutgoingFHCP`'`._

## Narrative

**Business context:** 生产管理 / 主计划 → 取消整单发外 (FHCP = 发回成品) — planner-grid button that pulls a previously-outsourced work-order back in-house. Clears the outsource flag on the work-order and matchbill, rolls the plan row back to `sState='2'` (active planning), and freezes any reported slave rows so they aren't re-touched by the scheduler.

**What it does:** Parses `$.params[*].value[*].sId`. For each plan id: `UPDATE mftworkordermaster SET bBillOutside=0` for the underlying `sWorkOrderId`; `UPDATE mftproductionplan SET sState='2'`; `UPDATE sgdsemigoodsmatchbillmaster SET bBillOutside=1` (kept marked as goods-coming-in); `UPDATE mftproductionplanslave SET bFrozen=1` for rows where `dProductionReportQty > 0`.

**Invocation:** Standard `Sp_<Module>_BtnEvent*` slot — dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` when the 主计划 grid's 取消整单发外 button names this procedure. Inverse: `Sp_productionMainPlan_BtnEventSingleOutgoing`. Companion: `Sp_productionMainPlan_BtnEventworkorder` (also undoes outsourcing but keyed by `mftworkordermaster.sId`, additionally calls `Sp_Manufacture_InsertMftPlan` to recreate the plan).
