# `Sp_Manufacture_MftPlanPhase_BtnEventCalc` (procedure)

> @author: 							
								@date:20220321  封存				
								@describe : 生产计划跟进(成品)							
								1.根据跟进阶段 印刷之后的阶段，创建表CalcProductsPhase，以备快速查询


- **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_Manufacture_MftPlanPhase_BtnEventCalc`'`._

## Narrative

**Business context:** 生产管理 → 生产计划管理 → 生产计划跟进表 — refresh-button for 生产计划跟进(部件) (printed parts side of the stage-tracking report). Per the COMMENT (@date 20220321 封存): "根据跟进阶段 印刷之后的阶段，创建表CalcProductsPhase，以备快速查询". Pre-computes the per-part-by-phase aggregate (`CalcProductContralsPhase`) so that the slow stage roll-up does not run on every page-load of the report.

**What it does:** Parses `$.params[*]` from `sProInParam` (`{"key":"slave","value":[{"sId":"..."}]}`). Builds temp `p_MftWorkOrderProcess` and `p_MftWorkOrder_Materials` from the work-order side, runs the post-印刷 phase aggregation per `eleprocessphase` order, and `UPDATE CalcProductContralsPhase` (and via `p_TempTable` / `mftproductionplan`) to refresh the cached stage rows.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — the 生产计划跟进(部件) report toolbar `计算` button names `Sp_Manufacture_MftPlanPhase_BtnEventCalc` as the action (`Sp_<Module>_BtnEvent*` pattern). Companion: `Sp_Manufacture_MftPlanPhase_productBtnEventCalc` does the 成品 variant. Install: xly-src `script/标版/30100101/schedule/Sp_Manufacture_MftPlanPhase_BtnEventCalc.sql`.
