# `Sp_KPI_SumByEmployee` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sStatistics` | `varchar(255)` |
| 2 | IN | `tStartDate` | `datetime` |
| 3 | IN | `tEndDate` | `datetime` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(255)` |
| 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_KPI_SumByEmployee`'`._

## Narrative

**Business context:** 人事行政 → KPI设置 → 员工KPI执行汇总(暂不开放) — aggregated KPI summary per employee over a date window. Sibling of `Sp_KPI_DetailByEmployee`; this view rolls the daily KPI rows up to per-employee totals. Wiki form-label flags 暂不开放 (not released).

**What it does:** Defaults `tStartDate` to NOW minus one month and `tEndDate` to NOW (`+1` day). Builds a `SELECT sUserName, SUM(iTodayOk), SUM(iTodayNo), SUM(iTodayTotal), SUM(iTodayStandard), AVG(iStandardRate), AVG(dCompRate), SUM(drewardMoney), SUM(dpunishmentMoney) FROM viw_kpimaster ... GROUP BY sUserName`. If `sStatistics` is supplied the WHERE adds `sUserName=sStatistics` for a single-employee summary. Hands off to `Sp_Outstanding_Query` for paging and count-JSON.

**Invocation:** Bound as the data source of form-master `15985934370006289064162987570000` (员工KPI执行汇总(暂不开放) — 人事行政 → KPI设置). Form is gated off per the 暂不开放 marker; not currently exposed to end users.
