# `Sp_MaterialAgingAnalysis_detail` (procedure)

> 材料库龄分析详情表


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 材料库存 — drill-down detail variant (header: 材料库龄分析详情表) of `Sp_MaterialAgingAnalysis`. Given one aging row (`iType`, `sMaterialsId`, `sMaterialsStyle`, `sWareHouseId`, `sLocationId`, `sDefineNo`, `sDefineNo2`), returns the underlying inventory rows that contributed to that bucket so the user can see exactly which 入库 / 调拨 entries are aging.

**What it does:** Reuses the `P_Tmp_sFromId` form-allow-list helper (populated via `INSERT into P_Tmp_sFromId`) and routes through `CALL Sp_Sis_GetMertialsInventoryFormGuid` to translate the inventory-type into the correct form GUID set, then builds `P_Tmp_Materials_List_Group` filtered to the requested material/style/location/define-nos. The output staging `P_Tmp_Materials_List_return` is paged via the standard `bFilter / sFilterOrderBy / sGroupby_*` contract.

**Invocation:** No form-master binding, no gdsmodule hook, no other-routine reference, no Java caller, no xly-src install script. Status: appears orphaned in this database — companion drill-down for the orphaned `Sp_MaterialAgingAnalysis`; would normally be wired to a detail-view popup off the parent report's row click.
