# `Sp_Manufacture_BtnEventCopyPlanSlave` (procedure)

> 复制一条计划


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `longtext` |
| 2 | IN | `sMakePerson` | `varchar(50)` |
| 3 | IN | `sBrId` | `varchar(50)` |
| 4 | IN | `sSuId` | `varchar(50)` |
| 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_Manufacture_BtnEventCopyPlanSlave`'`._

## Narrative

**Business context:** 生产管理 → 生产计划 → 机台计划 — 复制一条计划 button. Duplicates a selected 机台计划 row (`mftproductionplanslave`) with optionally rebound 工序 / 机台 / 班组 (taken from `$.changeValue` overrides); used to clone a similar plan line and quickly retarget it.

**What it does:** Parses `$.params[*].value[*].sId` for source rows and `$.changeValue.sProcessName / sMachineName / sTeamName` for overrides. Resolves the chosen 工序 from `eleprocess` (sId, sProcessNo) by `sProcessName`. For each source `sId`, reads the existing row's 工单/工序/机台/起止时间/排序 from `mftproductionplanslave`, computes a new `iOrder` and `tStartDate` (MAX in same team/group + 1) when 班组 override is provided, then `INSERT INTO MftProductionPlanSlave` a new row copying the source with overrides applied and a fresh sId.

**Invocation:** Dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — the 机台计划 grid's 复制 toolbar button names this proc by string. Install script: `script/标版/30100101/schedule/Sp_Manufacture_BtnEventCopyPlanSlave.sql` (comment: 复制一条计划).
