# `Sp_mes_TimeActivation_Work` (procedure)

> @author:zhucx
							@date:20210621 封存
							@describe: 工单执行效率


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tBetweenDate` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | IN | `bFilter` | `varchar(5000)` |
| 6 | IN | `pageNum` | `int` |
| 7 | IN | `pageSize` | `int` |
| 8 | OUT | `totalCount` | `int` |
| 9 | IN | `countCloumn` | `varchar(5000)` |
| 10 | OUT | `countMapJson` | `longtext` |
| 11 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 12 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 13 | 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_TimeActivation_Work`'`._

## Narrative

**Business context:** 生产管理 → 生产执行 → 生产实效分析 → 设备工单效率(暂不开放) — paged 工单执行效率 report grouping the same PLC + production-report data by 工单 (`sWorkOrderControlId` / `sSrcSlaveId`) instead of by machine or team. Sibling of `Sp_mes_TimeActivation_Machine`/`_Team`.

**What it does:** Defaults `p_tStartDate` to `NOW() - 1 MONTH` when no range is supplied; aggregates PLC stops (`dAdjustHour`, `dValidTime`, `dErroHour`, `dmaintainHour`, `dTotalTime`) from `p_bd_Tm`/`p_machinedata` joined to `mftworkordercontrol` and `mftproductionreport*`, grouped by 工单. Emits the same JSON_ARRAY `sTimeStatus` breakdown and `d*Rate`/`dOee` columns as the machine variant. Pagination is inline.

**Invocation:** Bound as the data-source of the 设备工单效率(暂不开放) form (`sParentId 19211681019715708748543080`) via `gdsconfigformmaster.sSqlStr` — under 生产实效分析 inside 生产执行. The 暂不开放 module label means the report is registered but hidden from menus; xly-src ships `script/标版/30100101/Sp_mes_TimeActivation_Work.sql` (install) and a `客户/亚明威` custom variant. Body marked 封存.
