# `Sp_Bd_bi20_2` (procedure)

> 单个机台时间分析


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 单个机台时间分析 — single-machine time-breakdown ring/pie chart for the 喷码现场 kanban. Companion to `Sp_Bd_bi20_1` (utilization gauge): `_1` reports the OEE %, `_2` reports the per-status hour decomposition (working / idle / changeover / waiting / ...) for the same machine.

**What it does:** Reads `elemachine` for `iPlcNo=sPlcNo` to resolve `p_sMachineGuid` + `sOffWork`/`sShiftsWork`/`sWorkType`. Computes shift window via `FUN_GET_DATE_BC_STARTDATE_NEW(NOW(),p_sOffWork,p_sShiftsWork)`. Aggregates `plc_machinedata.dProduceHour` GROUPED BY `sStatus` (with NULL collapsed to `waitingWork`) into `p_bd_EqStatus(sName,sValue,iOrder)`, joins `plc_machinedata_status` for the Chinese display name + color, and selects the per-status rows directly back to the caller (no JSON wrapping).

**Invocation:** Installed by `xly-src/script/标版/30100101/kanban/Sp_Bd_bi20_2.sql`. No form-master sSqlStr, no `gdsmodule` hook, called from `Sp_MachinePoweranalysis_1` and `Sp_MachineSpeedanalysis_1` via commented-out CALL lines (currently dead), no live caller, no Java caller. Status: appears reachable only via an external dashboard HTTP endpoint that invokes the proc by name. Per wiki scope, kanban dashboard procs sit outside the routine call-graph wiring tracked in this catalog.
