# `Sp_productionPlanInfo_CopyPlan` (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_CopyPlan`'`._

## Narrative

**Business context:** 生产管理 → 生产计划管理 → 生产排程 — toolbar handler "机台计划：复制排程" (clone schedule row) on `mftproductionplanslave`. Used to spawn an extra slave row off an existing finished-product (`sType='2'`) row when the planner needs a parallel run on a second machine or a re-execution.

**What it does:** Per dash-split `sId`: reads `bFrozen`, `sState`, `sType`. Refuses (`sCode=-1, LEAVE top`) if frozen ("已经冻结单子不能操作！") or if `sType<>'2'` ("非成品工序不能操作！"). Otherwise reads the row's order/parts/process/decompose key, then `INSERT INTO mftproductionplanslave(sId, sBrandsId, sSubsidiaryId, tCreateDate, … ~140 columns …) SELECT NewId() AS sId, sBrandsId, …` cloning every column except the primary key. Logs a 复制排程 row to `syslog` with `sFormId='101251240115016110217762400'`.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — 生产排程 form's "复制排程" button. xly-src ships `script/标版/30100101/schedule/Sp_productionPlanInfo_CopyPlan.sql`. Note: the bulk INSERT does not reset workflow flags (`sState`, `bProductionPlanComplete`, etc.) — the clone inherits the source row's progress, which the caller may need to clean up afterwards.
