# `Sp_productionPlan_BtnEventAutoOrder8` (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_BtnEventAutoOrder8`'`._

## Narrative

**Business context:** 生产管理 → 生产计划管理 → 生产排程 — 机台计划 auto-ordering button, sort strategy **按完工+计划时间排序** (by completion-date then planned-time). Variant 8 of the BtnEventAutoOrder family — schedules the machine queue by due-date urgency rather than by product/part structure.

**What it does:** Per-machine staging through `table_mftproductionplanslave_tmp` / `_tmp_after`, recomputes `iOrder` ordered by 完工日期 (completion date) then 计划时间 (planned time), then `UPDATE mftproductionplanslave SET iOrder=<computed>` for the chosen machine. Simpler staging than variants 3–6 (two worktables instead of five).

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