# `Sp_productionMainPlan_BtnEventReCovert` (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_BtnEventReCovert`'`._

## Narrative

**Business context:** 生产管理 / 主计划 → 恢复 — planner-grid "restore" toolbar button. Rolls a suspended/blocked plan row back to its prior state and thaws the underlying machine-schedule slaves so the work-order returns to active planning.

**What it does:** Reads the `CkxXd` flag from `syssystemsettings` (`p_bXd`, controls whether thaw lands on `sState='2'` or `'1'`). Parses `$.params[*].value[*].sId`. For each plan id (skipping `sState='5'` outsourced rows): `UPDATE mftproductionplan SET sState=sPriorState, sMaterialsCheckResult=` (recomputed against `tLastDeliverDate` vs `tDeliverDate`, "偏离交期" or "满足交期"). Then unfreezes all `mftproductionplanslave` rows under the work-order: `bFrozen=0, sState='2'` when `p_bXd=1` else `sState=1`.

**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_BtnEventReCovert.sql`. Counterparts: `Sp_productionMainPlan_BtnEventSuspend` (the inverse), `Sp_productionMainPlan_BtnEventResumeOrder` (restore-iorder variant).
