# `Sp_KPI_DetailByEmployee` (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_DetailByEmployee`'`._

## Narrative

**Business context:** 人事行政 → KPI设置 → 今日KPI完成情况(暂不开放) — per-day KPI detail view for one employee. Wiki form-label flags 暂不开放 (not currently released to users), so the report is staged-but-disabled in this build.

**What it does:** Defaults `tStartDate` to NOW minus one month and `tEndDate` to NOW (`+1` day for inclusive). Builds a `SELECT ... FROM viw_kpimaster` filtered by `sBrandsId` / `sSubsidiaryId` / `tCreateDate` window / `sUserName=sStatistics`, projecting daily KPI fields (`iTodayOk`, `iTodayNo`, `iTodayTotal`, `iTodayStandard`, `iStandardRate`, `dCompRate`, `drewardMoney`, `dpunishmentMoney`, `sUnTaskFromId`). Hands off to `Sp_Outstanding_Query` for paging, count-JSON, and group-by overrides.

**Invocation:** Bound as the data source of form-master `101251240115015986085696180` (今日KPI完成情况(暂不开放) — 人事行政 → KPI设置). Form is gated off in the UI per the 暂不开放 marker; the proc lives in the catalog but is not currently exposed to end users.
