# `Sp_Manufacture_InsertMftPlan` (procedure) > @author:钱豹 @date:20210711 封存 @describe: 生产计划:插入计划(工单审核,重新投入规划调用),主要功能: 1、根据工序中设定的 拆单方式 按贴,按付... 插入到机台计划表中 2、根据工单工序从表ID汇总数量 反写工单工序的已排程数 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sWorkOrderGuid` | `varchar(255)` | | 2 | IN | `sWorkOrderBillNo` | `varchar(100)` | | 3 | IN | `bCheck` | `int` | | 4 | IN | `sLoginId` | `varchar(100)` | | 5 | IN | `sBrId` | `varchar(100)` | | 6 | IN | `sSuId` | `varchar(100)` | | 7 | OUT | `sCode` | `int` | | 8 | OUT | `sReturn` | `varchar(5000)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Manufacture_InsertMftPlan`'`._ ## Narrative **Business context:** 生产管理 → 生产计划管理 — work-order (工单) plan-explosion engine. On work-order audit (审核) or re-plan (重新投入规划), it expands each work-order process row into `MftProductionPlanSlave` per the process's 拆单方式 (按贴/按付/...), then writes back the scheduled qty (`已排程数`) on the work-order process side. Per the COMMENT, owned by 钱豹, 封存 20210711. **What it does:** Iterates work-order processes for the given `sWorkOrderGuid` (or by `sWorkOrderBillNo`). `DELETE FROM MftProductionPlanSlave` for stale rows, `CALL Sp_GetMachineByApsRule` to pick the candidate machine per process, then re-inserts plan-slaves via the per-process detail helpers (the slave-level `Sp_Manufacture_InsertMftPlanSlave` is invoked indirectly). `UPDATE MftProductionPlanSlave` aggregations roll back to the work-order to refresh the `已排程数`. **Invocation:** Chained — called from `Sp_Calc_sSmb` (生产排单单审核), `Sp_Calc_sWod` (工单审核), `Sp_PLC_ScanInsertToERP`, `Sp_productionMainPlan_BtnEventPlanning`, `Sp_productionMainPlan_BtnEventworkorder`, `Sp_productionMainPlan_Process_BtnEventUnOutProcessing`, `Sp_commonList_BtnEventBillReturn`, and the dynamic `sp_btn_action` dispatcher. No direct form-master / `gdsmodule` hook binding. Install: xly-src `script/标版/30100101/schedule/Sp_Manufacture_InsertMftPlan.sql` plus several upgrade patches.