# `sp_mftproductionreportdata_employee_WageMoney` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `bSearchAll` | `int` |
| 2 | IN | `iType` | `int` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |
| 6 | IN | `bFilter` | `longtext` |
| 7 | IN | `pageNum` | `int` |
| 8 | IN | `pageSize` | `int` |
| 9 | OUT | `totalCount` | `int` |
| 10 | IN | `countCloumn` | `longtext` |
| 11 | OUT | `countMapJson` | `longtext` |
| 12 | IN | `sFilterOrderBy` | `longtext` |
| 13 | IN | `sGroupby_select_sql` | `longtext` |
| 14 | IN | `sGroupby_group_sql` | `longtext` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `sp_mftproductionreportdata_employee_WageMoney`'`._

## Narrative

**Business context:** 生产管理 → 计件工资 — paged piecework-wage query against `mftproductionreportmaster + mftproductionreportslave + mftproductionreportemployee` (报工单 master + product line + assigned employee). Each report-employee row carries the wage portion that worker earned on that production-report line; this proc aggregates those into the wage report with three modes (detail / monthly / daily).

**What it does:** Allocates temporary table `TMP_viw_mftproductionreportEmployee_VcPi` with employee/machine/team/process/product/customer keys plus `dHour`, `dProcessQty`, `dQualifiedProductionQty`, `dNoQualifiedProductQty`, `dMakeReadyMoney`, `dProductionReportWageMoney`. Translates JSON `bFilter` via `Fun_bFilter_toWhere`, then dynamically builds `INSERT INTO TMP_… SELECT … FROM mftproductionreportmaster B JOIN mftproductionreportslave S JOIN mftproductionreportemployee A WHERE S.bAffirm=1 AND B.bInvalid=0 …`. Three modes: `iType=1` detail per-row; `iType=2` monthly aggregate `GROUP BY sCreateDate(YYYYMM), sEmployeeId, sMachineId, sTeamId`; `iType=3` daily aggregate `GROUP BY YYYYMMDD, …, sTeamType`. Computes `totalCount` and `countMapJson` totals, then UPDATE-joins denormalised name columns from `eleprocess`/`eleproduct`/`eleemployee`/`elemachine`/`eleteam`/`elecustomer`, finally `SELECT * FROM TMP_…` paged.

**Invocation:** Status: appears orphaned. No caller found in any channel (form-master `sSqlStr`/`sConfigSqlStr`/`sSqlCondition`, gdsmodule hooks, other routines, xly-src grep across all extensions) — candidate for maintainer audit. The procedure body and parameter list match the standard outstanding-query report pattern, so it may have been intended for a 计件工资 grid that was never wired up, or is invoked from a tenant-specific form-master that isn't in this DB snapshot.
