# `Sp_bd_EqStatus_new` (procedure)

> @author:zhucx
							@date:20210620 封存
							@describe: 看板管理-数字工厂状态看板-右边


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sBrId` | `varchar(100)` |
| 2 | IN | `sSuId` | `varchar(100)` |

## Body

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

## Narrative

**Business context:** 看板管理 / 数字工厂状态看板 — right-side equipment-status donut. Revised version of `Sp_bd_EqStatus`: drops the bitmask-numeric decoder and instead takes each machine's latest `sStatus` row from `plc_machinedata` directly, counting machines per state.

**What it does:** For every `elemachine` row with `iPlcNo>0`, walks `plc_machinedata` ordered by `(sMachineId, iIncrement DESC)` with a window-rank emulation (`@sPsId`/`@rank`) to pick the single latest row per machine, groups by `sStatus`, and inserts counts into `p_bd_EqStatus`. Ensures `endWorked`/`offwork`/`abnormal`/`maintain`/... rows exist with zero default, then returns the donut payload as JSON. Inert "真实数据" alternative using `viw_plc_machine` and the bitmask decoder is retained commented-out.

**Invocation:** No install script under `xly-src/script/标版/30100101/`, no form-master sSqlStr, no `gdsmodule` hook, no other-routine caller, no Java caller. Status: appears orphaned. No caller found in any channel — candidate for maintainer audit. Likely reached only by a tenant-baked external dashboard endpoint that invokes the proc by name; both `_new` and the parent are marked `封存` (sealed) 2021-06-20.

Parameter signature drops `sLoginId`/`bFilter`/`sCode`/`sReturn` from the parent — leaves no way to surface state codes to the caller; the donut JSON is `SELECT`-emitted instead of returned via `sReturn`.
