# `Sp_productionMainPlan_BtnEventworkorder` (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_BtnEventworkorder`'`._

## Narrative

**Business context:** 生产管理 / 主计划 → 取消整单发外 (work-order-keyed variant) — companion to `Sp_productionMainPlan_BtnEventSingleOutgoingFHCP` that takes selected `mftworkordermaster.sId` ids instead of plan ids. Pulls the work-order back from outsourced and recreates its production-plan row via the manufacturing-plan-insert proc, so the cancellation also rebuilds the schedule entry that 整单发外 had stripped.

**What it does:** Parses `$.params[*].value[*].sId` as work-order ids. For each: `UPDATE mftworkordermaster SET bBillOutside=0`; `UPDATE mftproductionplan SET sState='3' WHERE sWorkOrderId=p_sId`; looks up `sBillNo` and calls `Sp_Manufacture_InsertMftPlan(p_sId, @sBillNo, 1, sMakePerson, sBrId, sSuId, sCode, sReturn)` to rebuild the plan row.

**Invocation:** Standard `Sp_<Module>_BtnEvent*` slot — dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` when the 主计划 / 工单 grid's 取消发外 (work-order keyed) button names this procedure. xly-src ships `script/标版/30100101/Sp_productionMainPlan_BtnEventworkorder.sql`. Companion: `Sp_productionMainPlan_BtnEventSingleOutgoingFHCP` (plan-id keyed).
