# `Sp_Waste_details_product` (procedure)

> 成品核检废明细-wx-12-17


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 质量管理 → 报废分析 — paged 成品核检废明细 report ("finished-goods inspection-waste detail", header tagged `wx-12-17`). Lists every produced work-order/product card and its 工序报废 (`dProcessWasteQty`) + 品检报废 (`dQualityInspectionWasteQty`) totals, with master-side context (customer, product, schedule warning, work-order stage).

**What it does:** From `viw_mftworkorder_copy1` filters to `sFormId in ('101251240115016002469445380','20240312202019690261117124589280')` (the two finished-goods card forms), `sOrderBusinessType<>'ZS01-5' AND <>'ZS06'`, `bProd=1`, `bcheck=1`. For each work-order row aggregates `SUM(dProcessWasteQty)` and `SUM(dQualityInspectionWasteQty)` from `hrmftworkorderprocess` where `bTypeWork=1`. Wires customer-tree filter `[sCustomerId, sLookCustomer]` and rewrites `bFilter`'s `A.sProductNo` → `E.sProductNo` to match the join alias. Hands the SQL to `sp_groupby` for `pageNum`/`pageSize`/`countCloumn` paging.

**Invocation:** Status: appears orphaned. The paged-report signature is the standard form-data-source pattern, but no `gdsconfigformmaster` references it, no gdsmodule hook, no other proc, no xly-src grep. The `wx-12-17` author tag and the commented-out SELECT template at the top of the body suggest it was authored as a report draft but never bound to a form `sSqlStr`. Candidate for maintainer audit.
