# `Sp_bd_team_TmAnalysis` (procedure)

> 单个机台时间分析


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sPlcNo` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | OUT | `sCode` | `int` |
| 5 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 看板管理 — "单个机台时间分析" donut tile. Variant of `Sp_bd_TmAnalysis` that drops the per-machine and per-shift-window filters: aggregates time-by-status across the full `plc_machinedata` history (filter clauses are commented out).

**What it does:** Resolves `sMachineGuid` from `elemachine` by `iPlcNo`/`sBrandsId`/`sSubsidiaryId` (the value is not actually used as a filter), then SUMs `dProduceHour` grouped by `sStatus` (with empty `sStatus` coerced to `waitingWork`) across **all** `plc_machinedata` rows. Each status is translated to its Chinese label (生产中 / 下班停机 / 设备异常 / 设备保养 / 文件异常 / 纸张异常 / 待料异常 / 切换调机) and serialised to a JSON donut payload `{"data":[{"x":<label>,"y":<hours>}...],"subTitle":"总时间"}` via OUT `sReturn`.

**Invocation:** No install script in xly-src, no form-master, no `gdsmodule` hook, no Java caller, no other-routine caller. Reached only by an external dashboard HTTP endpoint that calls the proc by name. With the machine-id and date filters commented out the proc effectively ignores its `sPlcNo` argument — output is the global, all-time status time-share rather than the per-shift, per-machine breakdown the name implies.
