# `Sp_bd_McPlanRate` (procedure)

> 计划达标率（实际产量/计划产量）


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sLoginId` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `bFilter` | `varchar(5000)` |
| 5 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `longtext` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_bd_McPlanRate`'`._

## Narrative

**Business context:** 看板管理 — "计划达标率（实际产量/计划产量）" dashboard tile. Returns the plan-attainment percentage per machine: actual produced counter divided by the planned counter for the active shift.

**What it does:** Materialises `p_bd_McPlanCount` from `mftproductionplanslave` (where `sState IN ('2','3')`, restricted to PLC-mapped machines via `elemachine.iPlcNo BETWEEN 1 AND 7`, anchored by `Fun_GetMachineWorkStartDate`), then materialises `p_machinedata` from `plc_machinedata` for the same set and computes the ratio per machine, formatting the result as the JSON object the dashboard renderer expects.

**Invocation:** Installed by `xly-src/script/标版/30100101/Sp_bd_McPlanRate.sql`. No form-master, no `gdsmodule` hook, no other-routine caller, no Java caller. Reached only by an external dashboard HTTP endpoint that calls the proc by name.
