# `Sp_bd_EqStatus` (procedure)

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


- **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_EqStatus`'`._

## Narrative

**Business context:** 看板管理 / 数字工厂状态看板 — right-side equipment-status donut showing the count of machines currently in each PLC state bucket (`endWorked`/`waitingWork`/`waitError`/`PaperError`/`fileError`/`maintain`/`abnormal`/`offwork`/`wait`). Author tagged `封存` 2021-06-20.

**What it does:** Reads `viw_plc_machine` where `sPlcsStatusName='当前设备状态'`, groups by `sPlcsStatusValue`, decodes the bitmask numeric codes (`256=endWorked`, `64=waitError`, `32=PaperError`, `16=fileError`, `8=maintain`, `4=abnormal`, `2=offwork`, else `wait`) into named buckets, ensures every bucket exists in `p_bd_EqStatus` even with zero count, and serialises to JSON `{"data":[{"x":"<sName>","y":<count>}], "subTitle":"机台总数",...}`. The body retains both the live PLC-filter block and an `MOD(iPlcNo,14) BETWEEN 1 AND 12` test-PLC-exclusion fork (the latter commented out as "真实数据" vs "模拟数据").

**Invocation:** Installed by `xly-src/script/标版/30100101/Sp_bd_EqStatus.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. Marked `封存` (sealed) — superseded by `Sp_bd_EqStatus_new`.
