# `Sp_bd_EqLoad` (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_EqLoad`'`._

## Narrative

**Business context:** 设备负荷 — equipment-load top-N bar chart on the 看板管理 / 数字工厂 dashboard. For each machine, divides the scheduled work-order processing quantity by `dAvgRate × dWeek` (machine's average per-hour rate × weekly working days) to estimate days of backlog, returning the 18 most-loaded machines.

**What it does:** Aggregates `mftproductionplanslave.dProcessQty` joined to `elemachine` for `sState IN (2,3)` (排程/生产中) under the current `sBrId`/`sSuId`, computes `CEILING(SUM(dProcessQty) / (dAvgRate × dWeek))` per `sMachineName`, orders by `dProcessQty DESC LIMIT 18`, and serializes the result to JSON `{"data":[{"x":<dHour>,"y":"<sMachineName>"}], "xUnit":"天","yUnit":""}` into `sReturn`.

**Invocation:** Installed by `xly-src/script/标版/30100101/Sp_bd_EqLoad.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. Per family convention, kanban/dashboard procs sit outside the routine call-graph wiring tracked in this catalog.

Falls back to defaults `dAvgRate=3000`, `dWeek=8` when `elemachine` columns are zero — re-mapping needed if cloned to a tenant where machine averages were never seeded.
