# `Sp_productionPlan_BtnEventAutoOrder4` (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_BtnEventAutoOrder4`'`._

## Narrative

**Business context:** 生产管理 → 生产计划管理 → 生产排程 — 机台计划 auto-ordering button, sort strategy **工单-部件-正正反反** (work-order → component → front/back grouping). Variant 4 of the BtnEventAutoOrder family — same keys as variant 3 but with 部件 swapped ahead of 正反.

**What it does:** Per-machine staging through `p_mftproductionplanslave_tmp*` worktables (tmp / tmpW / tmp_order / tmp_after / tmp_update), recomputes `iOrder` ordered 工单 → 部件 → 正正反反, then `UPDATE mftproductionplanslave SET iOrder=<computed>` for matching rows.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — 自动排序 toolbar option on 生产排程. xly-src ships `script/标版/30100101/schedule/Sp_productionPlan_BtnEventAutoOrder4.sql` (install script only).
