# `Sp_mes_TeamQtyReported` (procedure)

> MES产量统计表


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

## Parameters

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

## Narrative

**Business context:** 生产管理 → 生产执行 → 数据采集与设备控制 → MES产量报表 — paged班组/机台产量统计 report. For a date range it rolls up `mftproductionreport*` production into a per-(机台, 班组, 工单) per-day grid showing actual qty, adjustable qty, hours, std hours, and abnormal hours so production managers can review reported output against the standard.

**What it does:** Splits `tBetweenDate` into `p_tStartDate`/`p_tEndDate` (defaults to last 24h when no range), builds temp table `t_mftproductionreport` with the per-slave shape, populates it by joining `mftproductionreportslave` with `mftworkordercontrol`/`elemachine`/`siswetteam`/`elematerials` etc., then aggregates into `p_mes_TeamQtyReported` (SUM by 机台×班组×单据), computes `dHourDif`/`dAdjustHourDif`/`dDif` against the standard, and finally calls `Sp_Do_UpdateByPageSizeBefore` to apply `bFilter`/order-by/pagination and emit `totalCount`+`countMapJson`. Returns the paged rows ordered by `sMachineId, sTeamId, tCreateDate`.

**Invocation:** Bound as the data-source of:
- MES产量报表 form (`sParentId 19211681019715708755429100`) — 生产执行 → 数据采集与设备控制
- 小模块-工单效率分析 form (`sParentId 192116812119216122418781640`) — 大屏展示

via `gdsconfigformmaster.sSqlStr`. Loaded when the operator opens either report. xly-src ships `script/标版/30100101/schedule/Sp_mes_TeamQtyReported.sql` (install) and a `客户/亚明威` custom variant.
