# `Sp_DailyStatisticalReport` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sLoginId` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 生产管理 → 产量日汇总报表 — daily-summary aggregator for production reports. Rebuilds `mftDaySumReport` for a chosen date range by re-aggregating `mftproductionreportslave` × `mftproductionreportemployee` per `(tVestingDate, sTeamType, sMachineId, sTeamId, sEmployeeId)`, then back-writes the new summary id onto each contributing employee row.

**What it does:** Validates `sProInParam`, extracts `$.changeValue.pChooseDate` (a `[start,end]` array), parses both ends into `p_tStartDate`/`p_tEndDate`. Deletes existing `mftDaySumReport` rows in that window for the tenant, then `INSERT INTO mftDaySumReport SELECT ...` summing `dProcessQty/dConversionQty/dHour/dQualifiedProductionQty/...` from the joined slave+employee tables grouped by date+team+machine+employee. Final `UPDATE mftproductionreportemployee` joins back to set `sDaySumReportId` on each employee row and stamps the slave's `sConfirmDayInfo='2'`. Empty params returns `paramsErro`.

**Invocation:** Status: appears orphaned. No caller in any channel — no `gdsconfigformmaster` binding, no `gdsmodule` hook, no other routine references, no Java reference in xly-src (only the install script `script/标版/30100101/Sp_DailyStatisticalReport.sql`). The JSON-param shape with `$.changeValue.pChooseDate` matches the standard sp_btn_action button signature, so the binding probably lives on a form button that's been removed; the monthly counterpart `Sp_MonthlyStatisticalReport` exists alongside it. Candidate for maintainer audit before reliance.
