# `Sp_productionMainPlan_BtnEventUnBlock` (procedure)

> 主计划：锁定 状态为8


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

## Narrative

**Business context:** 生产管理 / 主计划 → 解锁 — planner-grid "release resource lock" button. Inverse of `Sp_productionMainPlan_BtnEventBlock`: unwinds a plan row that was pinned at `sState='8'` (locked) so the machine-scheduler regains scheduling freedom on its time window. (The COMMENT "锁定 状态为8" is misleading — body actually unlocks.)

**What it does:** Parses `$.params[*].value[*].sId`. For each plan id: refuses with `sCode=-8` and localised `sProductionMainPlanResourceUnLocked` ("资源未锁定，无需释放资源") if `sState <> '8'`. Otherwise: `UPDATE mftproductionplan SET sState = IF(sPriorState='8', 2, sPriorState), sPriorState = p_sState` (so block→unblock leaves a sane state); then `UPDATE mftproductionplanslave SET bEmploy=0, sEmployPerson='', tEmploytime=NULL` for every row keyed by the plan's `sWorkOrderId`.

**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_BtnEventUnBlock.sql`. Inverse: `Sp_productionMainPlan_BtnEventBlock`. Per-slave-row variant: `Sp_productionMainPlan_BtnEventUnBlockOne`.
