# `Sp_Bd_Root_Production` (procedure)

> 通用界面自定义模板1


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 看板管理 — production-board template ("通用界面自定义模板1"). Aggregates current PLC machine-status counts plus today's activity totals (工单 / 入库 / 送货 / 异常 etc.) for the production overview tile.

**What it does:** Fills `p_ProductionBoard(sName,sValue)` with a date stamp and fixed-string environment readings (`temperature=27.6度`, `humidity=56.2%`), then runs a window-ranked subquery on `plc_machinedata` (latest non-`endWorked` status per `sMachineId`, ranked by `tStartDate desc`) and groups by `sStatus` to count machines in each state. Pads the standard buckets (`startWorking` / `offwork` / `abnormal` / `maintain` / `fileError` / `PaperError` / `waitError`) with 0 when missing, then appends today's COUNT for `mftworkordermaster`, `pitproductinstoremaster`, and other activity tables.

**Invocation:** Installed by `xly-src/script/标版/30100101/Sp_Bd_Root_Production.sql`. No form-master, no `gdsmodule` hook, no Java caller, no other-routine caller. Reached only by an external dashboard HTTP endpoint that calls the proc by name. The hard-coded temperature/humidity strings indicate this is a demo template, not a live tile — verify before relying on it.
