# `Sp_mes_TimeActivation_Team` (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_Team`'`._

## Narrative

**Business context:** 生产管理 → 生产执行 → 数据采集与设备控制 → 班组稼动率 — twin of `Sp_mes_TimeActivation_Machine` but grouped by `sTeamId` (班组) rather than machine. Returns each team's调试/生产中/生产异常/设备保养 minute totals plus derived rate columns, so the MES dashboard can rank teams by availability.

**What it does:** Same PLC + production-report aggregation pipeline as the machine variant: populates `p_bd_Tm` etc. from `plc_machinedata`, `mftproductionreport*`, and team/machine masters, then aggregates by `sTeamId` with the same JSON_ARRAY `sTimeStatus` and `dErroHourRate`/`dValidTimeRate`/`dAdjustHourRate`/`dmaintainHourRate`/`dOee` columns. Date range comes from `tBetweenDate`; `bFilter`/pagination applied inline.

**Invocation:** Bound as the data-source of the 班组稼动率 form (`sParentId 19211681019715708722709010`) via `gdsconfigformmaster.sSqlStr` — under 数据采集与设备控制 inside 生产执行. xly-src ships `script/标版/30100101/Sp_mes_TimeActivation_Team.sql` (install) and a `客户/亚明威` custom variant. Body marked 封存 (frozen).
