# `Sp_mes_TimeanalyseMonth_Machine` (procedure)

> @author:zhucx
                @date:20210621 封存
                @describe: 机器时间分析


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `psMonth` | `varchar(100)` |
| 2 | IN | `psMachineId` | `varchar(100)` |
| 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_mes_TimeanalyseMonth_Machine`'`._

## Narrative

**Business context:** 生产管理 → 生产执行 → 数据采集与设备控制 — month-window twin of `Sp_mes_Timeanalyse_Machine`: 机器时间分析月度. Same dynamic-column shape (one column per PLC `sStatus`) but the date range is derived from `psMonth` (`YYYYMM`) rather than `tBetweenDate`.

**What it does:** Computes month start/end from `psMonth`, populates `p_bd_Tm`/`p_machinedata`/`p_bd_Tm_erro_detial` from `plc_machinedata` and machine masters for that month, then iterates over distinct `sStatus` values to `ALTER` and `UPDATE` `p_bd_Tm_return` so each status becomes its own column. Returns the table plus a JSON `sColumnNameConfig` for the front-end.

**Invocation:** Status: appears orphaned. No `gdsconfigformmaster`/`gdsmodule` reference, no caller proc, no xly-src hit. The 月度 form likely was rewritten or never enabled. Candidate for maintainer audit. Body marked 封存.
