# `Sp_bd_MachinePlanDate` (procedure)

> 车间效率综合看板-根


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sPlcNo` | `varchar(100)` |
| 2 | IN | `sFormGuid` | `varchar(100)` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | OUT | `sReturn` | `varchar(4000)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 车间效率综合看板-根 — workshop comprehensive-efficiency kanban root payload for one machine. Returns the full set of name/value pairs (date, work-order, team, plan vs report quantities, OEE) consumed by the front-end's `commonAuto` template.

**What it does:** Resolves the machine from `elemachine` by `iPlcNo=sPlcNo`, derives the current `sWorkType` (`sOffWork`/`sShiftsWork`) by comparing `NOW()` against shift boundaries, and computes the team's `tStartDate`. Inserts per-metric rows into `p_bd_MachinePlanDate(sName,sValue)` for keys including 'sMachineName', 'sWorkOrderNo', 'sTeamName', 'dDayPlanQty' (default 8000), 'dMonthPlanQty' (default 240000), and report-quantity aggregates pulled from `plc_machinedata`/`mftproductionplanslave`. Final SELECT emits the table as the kanban JSON envelope.

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

Hardcoded defaults `dDayPlanQty=8000`/`dMonthPlanQty=240000` when `elemachine` plan columns are zero — re-mapping needed for tenants with different target quantities.
