# `Sp_MachinePoweranalysis_1` (procedure)

> 单个机台各时段用电分析


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `p_sMachineId` | `varchar(100)` |
| 4 | IN | `p_sTeamId` | `varchar(100)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | OUT | `sCode` | `int` |
| 8 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 生产管理 → 设备能耗看板 — single-machine dashboard chart returning the 设备状态-bucketed 能耗 pie/donut data (sName=`sStatus`, sValue=度数 sum). Drill-in companion of `Sp_MachinePoweranalysis` (the paged grid).

**What it does:** Reads `elemachine.sOffWork`/`sShiftsWork` for the given `p_sMachineId` (defaults `8:00`/`17:30`), shifts `tStartDate`/`tEndDate` to those shift boundaries, drops/creates `p_bd_EqStatus(sName, sValue)`, and `INSERT … SELECT P.sStatus, SUM(dElectricityQty) FROM plc_machinedata` filtered by `sMachineId` (and optionally `sTeamId` when provided) within the shift window. Returns `sReturn` as a `{"data": [{"x": …, "y": …}, …]}` JSON via `GROUP_CONCAT` over the temp.

**Invocation:** Status: appears orphaned. The proc body has a commented-out hint `-- Call Sp_Bd_bi20_2_nomes(7,…)` suggesting it was intended for the BI dashboard family. No `gdsconfigcharmaster.sProcedureName` binding, no `gdsmodule.sProcName`, no caller in xly-src or other routines, no install script. The `{"data":[{x,y}]}` JSON output shape matches chart-master conventions — candidate for maintainer audit to confirm which dashboard tile owns it.
