# `Sp_MachineSpeedanalysis` (procedure)

> 设备速度分析


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | IN | `bFilter` | `varchar(5000)` |
| 7 | IN | `pageNum` | `int` |
| 8 | IN | `pageSize` | `int` |
| 9 | OUT | `totalCount` | `int` |
| 10 | IN | `countCloumn` | `varchar(5000)` |
| 11 | OUT | `countMapJson` | `longtext` |
| 12 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 13 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 14 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 生产管理 → 设备速度分析 — paged-grid 设备速度 report. Lists every active `elemachine` (`bInvalid = 0`) and rolls up 运行时长 from `plc_machinedata` over a date window grouped by 机型 (`sFilterOrderBy` defaults to `ORDER BY sMachineType`).

**What it does:** Defaults `tStartDate` to one month ago, `tEndDate` to NOW. Drops/creates `Tmp_elemachine_1` populated from `elemachine`, then aggregates `plc_machinedata` into `p_bd_EqStatus_1` (sum of `dProduceHour/3600` per machine). `UPDATE Tmp_elemachine_1` joins by `sMachineId` to copy `dTotalTime`, then `CALL Sp_Do_UpdateByPageSizeBefore` to paginate.

**Invocation:** Status: appears orphaned by formal channels. No `gdsmodule.sProcName`/`sSaveProName*` hook, no `gdsconfigformmaster.sSqlStr` binding, no other-routine reference, no install script in xly-src. The paged-report signature implies it was intended as a form data-source — candidate for maintainer audit. Drill-in dashboards: `Sp_MachineSpeedanalysis_1` (per-machine 时间-状态 breakdown), `Sp_MachineSpeedanalysis_2` (per-machine 折线 of dRate over time).
