# `Sp_productionPlanInfo_BtnEventRecommendMachine` (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_productionPlanInfo_BtnEventRecommendMachine`'`._

## Narrative

**Business context:** 生产管理 → 生产计划管理 → 生产排程 — toolbar handler "使用推荐机台" (apply recommended machine) on `mftproductionplanslave`. Copies the APS-recommended machine `sTjMachineId` into the live machine columns so the slave row is officially scheduled onto that machine without manual entry.

**What it does:** Per slave `sId` from `sProInParam.params[*].value[*].sId`: `UPDATE mftproductionplanslave S INNER JOIN elemachine E ON E.sId=S.sTjMachineId INNER JOIN sisworkcenter W ON W.sId=E.sCostCenterId SET S.sMachineId=S.sTjMachineId, S.sMachineNo=E.sMachineNo, S.sMachineName=E.sMachineName, S.sWorkCenterId=E.sCostCenterId, S.sWorkCenterName=W.sName, S.sState=if(IFNULL(S.sState,0)=0,2,S.sState)` where `IFNULL(S.sTjMachineId,'') <> ''` and tenant matches. State auto-jumps from 0 (待排) to 2 (已排) when the recommendation is applied.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — 生产排程 form's "使用推荐机台" button. xly-src ships `script/标版/30100101/schedule/Sp_productionPlanInfo_BtnEventRecommendMachine.sql`.
