# `Sp_Inventory_ProductInventory_Outdated` (procedure)


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 成品库存 → 预警报表 → 产品库存呆滞预警表 — slow-moving / outdated (呆滞) finished-product warning report. Surfaces finished goods with on-hand qty above zero that have not moved for the configured period; sibling procs `_Customer` and `_Salesman` re-slice the same data by customer and salesperson dimensions.

**What it does:** Defaults `iType=0` and clears NULLs. Builds temp table `TMP_TmpDatedProducts` mirroring `eleproductstock` (sId, product / 自定义项 / warehouse / location, qty, price, money, inventory/created/checked/production dates, work-order and order linkage, `bFrozen`, customer and product display fields). Populates it from `eleproductstock` joined to recent movement signals, computes the staleness window per `iType`, and emits the rowset paginated via `Sp_Outstanding_Query` with count-aggregation JSON.

**Invocation:** Bound as the data source of form-master `19211681015115285256391940` (产品库存呆滞预警表 — 成品库存 → 预警报表). Function `Fun_getInitColumnByProName` references it for column metadata. xly-src ships `script/标版/30100101/Sp_Inventory_ProductInventory_Outdated.sql` plus `_Customer` and `_Salesman` companion procs for the dimension-sliced views, and `script/标版/optimize/Sp_Inventory_ProductInventory_Outdated.sql`.
