# `Sp_Bd_Root_allstatus_2` (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` | `longtext` |

## Body

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

## Narrative

**Business context:** 看板管理 / 数字工厂状态看板 — "采购数据展示" tile (bottom of board). Shows purchase totals (万元) bucketed by `elematerials.sMaterialsType` (材料分类): paper / label / finished / half_finished / corrugated / sMach_accessories / 辅料. Author tagged `封存` 2021-06-20.

**What it does:** Seeds `p_Root_allstatus_2` with one row per distinct `elematerials.sMaterialsType` at 0. Joins `viw_purpurchaseorder` (`bCheck=1`, **no date filter — the "本月" filter is commented out**) with `elematerials` and sums `dMaterialsMoney/10000` plus a 100 offset per bucket. Translates the internal codes to Chinese labels (`paper`→纸张, `label`→不干胶, `finished`→成品, `half_finished`→半成品, `corrugated`→瓦楞, `sMach_accessories`→设备配件, else 辅料) and serialises to JSON `{"data":[{"x":<name>,"y":<value>}...],"yUnit":"万"}` via OUT `sReturn`.

**Invocation:** Installed by `xly-src/script/标版/30100101/Sp_Bd_Root_allstatus_2.sql`. No form-master, no `gdsmodule` hook, no Java caller, no other-routine caller. Reached only by an external dashboard HTTP endpoint. Marked `封存` (sealed); the `+100` offset means output is partly demo data and the commented-out date filter means the sum spans all history rather than the current month — verify before relying on it.
