# `Sp_productionPlan_BtnEventLockSd` (procedure)

> 生产计划跟进-锁定或修改所选生产计划


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `longtext` |
| 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_productionPlan_BtnEventLockSd`'`._

## Narrative

**Business context:** 生产计划管理 → 生管主计划 / 生产排程 — 生产计划跟进-锁定或修改所选生产计划 (per the proc's COMMENT). Locks the selected `mftproductionplanslave` schedule rows for a machine while bumping all later rows on the same machine to make room.

**What it does:** Validates `sMachineId` and the `sRowData` JSON array (returns `sNotChoose` / `sManufactureChooseMachine` constants on miss). Loads the chosen `sId`s into a `p_Lock` temp table, captures `MIN(iOrder)/MAX(iOrder)` over those rows, then `UPDATE mftproductionplanslave` to shift `iOrder` of all other locked rows on the same machine past that range (skipping `sState=5`, completed, or already-in-lock rows). Finally `UPDATE` the chosen rows to set `tLock=NOW(), sLock=sMakePerson, bLock=1`.

**Invocation:** Bound to a 锁定 toolbar action on the 排程信息表 / 排程从表 grids under 生产排程; dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()`. No xly-src caller surfaced via grep — DB-only at present. Paired uncheck: `Sp_productionPlan_BtnEventLockSd_cnl` (called by `Sp_productionPlan_BtnEventCnl`).
