# `Sp_ProductAgingAnalysis_detail` (procedure)

> 产品账龄分析


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iType` | `int` |
| 2 | IN | `sProductId` | `varchar(100)` |
| 3 | IN | `sWareHouseId` | `varchar(100)` |
| 4 | IN | `sLocationId` | `varchar(100)` |
| 5 | IN | `sWareHouseLocationId` | `varchar(100)` |
| 6 | IN | `sDefineNo` | `varchar(100)` |
| 7 | IN | `sDefineNo2` | `varchar(100)` |
| 8 | IN | `sBrId` | `varchar(100)` |
| 9 | IN | `sSuId` | `varchar(100)` |
| 10 | IN | `sLoginId` | `varchar(100)` |
| 11 | IN | `bFilter` | `text` |
| 12 | IN | `pageNum` | `int` |
| 13 | IN | `pageSize` | `int` |
| 14 | OUT | `totalCount` | `int` |
| 15 | IN | `countCloumn` | `varchar(5000)` |
| 16 | OUT | `countMapJson` | `longtext` |
| 17 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 18 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 19 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 销售管理 / 库存 → 产品账龄分析 — drill-down variant of `Sp_ProductAgingAnalysis` that returns the row-level detail for a single product/warehouse/location/lot from the summary grid. Accepts `iType`, `sProductId`, `sWareHouseId`, `sLocationId`, `sWareHouseLocationId`, `sDefineNo`, `sDefineNo2` so the drill is scoped to whichever cell the user clicked.

**What it does:** Same scaffolding as the summary proc — `CALL Sp_Sis_GetProductInventoryFormGuid` into `P_Tmp_sFromId`, builds `P_Tmp_product_List_detail` and `P_Tmp_product_List_return` joining `eleproductstock`, `viw_salsalesorder`, `elecustomer`, `eleproductcustomer`, `eleproduct`, `sislocation`, `siswarehouse`, `SisCurrency`, `SisSalesMan`. Filters on the drill-down keys, then hands the dynamic SQL to the standard paging/order-by/groupby helper that flushes `totalCount` and `countMapJson`.

**Invocation:** No live form-master / gdsmodule / other-proc binding for this name in `xlyweberp_saas_ai`. Typical deployment registers it as the dataSource of a hidden drill-detail form_sId opened from the `Sp_ProductAgingAnalysis` grid; that wiring is customer-specific and not in 30100101. Audit candidate.
