# `Sp_bd_EqTime` (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` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 时间稼动率 — time-utilization bar chart on the 看板管理 / 数字工厂 dashboard. Counterpart of `Sp_bd_EqSpeed` (speed) and `Sp_bd_MachineOee` (composite OEE). For each MES-instrumented machine, returns valid-production-time divided by total-time over the last 24-hour shift window.

**What it does:** Materialises `p_bd_EqTime` from `elemachine` filtered to `iPlcNo>0` and `MOD(iPlcNo,14) BETWEEN 1 AND 12` (test-PLC exemption) under the current `sBrId`/`sSuId`. Walks `plc_machinedata` between yesterday's `sOffWork` and today's `sOffWork` per-machine, summing `dProduceHour` into `dValidTime` (status=`endWorked` AND `dAdjustableQty=0`, plus `waitingWork` rows under 6 minutes) and `dTotalTime` (status≠`offwork`). Returns JSON `{"data":[{"x":<utilizationPct>,"y":"<sMachineName>"}], "xUnit":"%","yUnit":""}` capped per the cohort's display convention.

**Invocation:** Installed by `xly-src/script/标版/30100101/Sp_bd_EqTime.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.

Tenant-specific test-PLC exemption (`MOD(iPlcNo,14) BETWEEN 1 AND 12`) — re-mapping needed if PLC numbering differs.
