# `Sp_productionPlan_BtnEventLock24Hour` (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_productionPlan_BtnEventLock24Hour`'`._

## Narrative

**Business context:** 生产计划管理 → 生管主计划 / 生产排程 — 计划锁定：移动到计划确认表 (per the COMMENT). 锁定24H机台任务: snapshots every plan row from `mftproductionplanslave` on a machine that falls inside the current shift (per `FUN_GET_DATE_BC` against the machine's `sWorkType`/`sShiftsWork`/`sOffWork`) into `mftproductionplanslavelock`, locks the originals, and writes an audit row to `syslog` ("锁定24H机台任务").

**What it does:** Loops the `$.params[*].value[*]` JSON array. For each `(sMachineId, tStartDate)` pair: resolves the current 班次 via `FUN_GET_DATE_BC` and machine fields from `elemachine`; aborts with `sProductionPlanNoGetMachineNum` / `sProductionPlanNoGetChooseClasses` / `sProductionPlanNoGetNowClasses` constants on miss. Builds temp tables for the active-shift slave rows (`MftProductionPlanSlave_Tmp_div`) and existing locks (`mftproductionplanslavelock_Tmp_div`), `INSERT INTO mftproductionplanslavelock` the rows not yet locked, then `UPDATE mftproductionplanslave` setting `bLock=1, sLock, tLock=NOW()`. Finally inserts a 浏览器-source `syslog` row stamped with `sFormId='19211681019715708440774010'` (生管主计划).

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` from the 锁定24H 工具栏 button on 生产主计划主表（按钮）/ 排程信息表 grids. xly-src `script/标版/30100101/schedule/Sp_productionPlan_BtnEventLock24Hour.sql` ships the install copy. Paired variant: `Sp_productionPlan_BtnEventLock24HourNotCalcTime` (skips time-recalc).
