# `Sp_productionMainPlan_BtnEventDelPlan` (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_productionMainPlan_BtnEventDelPlan`'`._

## Narrative

**Business context:** 生产管理 / 主计划 → 删除计划 — planner-grid "delete plan" button. Removes selected `mftproductionplan` master rows and their unused slave rows, but refuses any row whose source work-order has been audited (`bFrozen=0` means audited — the proc's check uses `bFrozen=0` as the refusal trigger, so an audited work-order's plan can't be deleted until the work-order is un-audited).

**What it does:** Parses `$.params[*].value[*].sId`. For each id, reads `(bFrozen, sSrcNo)` from `mftproductionplan`. If `bFrozen=0` returns `sCode=0` and `sReturn = sSrcNo,'已审核,不能删除,请先消审工单'`. Otherwise: `DELETE FROM mftproductionplanslave WHERE bFrozen=1 AND IFNULL(dProductionReportQty,0)=0 AND sWorkOrderId IN (SELECT sWorkOrderId FROM mftproductionplan WHERE sId=p_sId)` (drops slave rows that have no production reported), then `DELETE FROM mftproductionplan WHERE sId=p_sId AND bFrozen=1`.

**Invocation:** Standard `Sp_<Module>_BtnEvent*` slot — dispatched by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` when the 主计划 grid's 删除计划 button names this procedure. xly-src ships `script/标版/30100101/Sp_productionMainPlan_BtnEventDelPlan.sql`. No form-master or gdsmodule binding.
