# `Sp_Inventory_MaterialsInOutStoreDoing` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sMaterialsGuid` | `varchar(255)` |
| 2 | IN | `sMaterialsName` | `varchar(255)` |
| 3 | IN | `sParentGuid` | `varchar(255)` |
| 4 | IN | `sWarehouseGuid` | `varchar(255)` |
| 5 | IN | `sDefineNoS` | `varchar(255)` |
| 6 | IN | `sDefineNoS2` | `varchar(255)` |
| 7 | IN | `tStartDate` | `datetime` |
| 8 | IN | `tEndDate` | `datetime` |
| 9 | IN | `iViewOperation` | `int` |
| 10 | IN | `sBrId` | `varchar(255)` |
| 11 | IN | `sSuId` | `varchar(255)` |
| 12 | IN | `bFilter` | `varchar(5000)` |
| 13 | IN | `pageNum` | `int` |
| 14 | IN | `pageSize` | `int` |
| 15 | OUT | `totalCount` | `int` |
| 16 | IN | `countCloumn` | `varchar(5000)` |
| 17 | OUT | `countMapJson` | `longtext` |
| 18 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 19 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 20 | 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_MaterialsInOutStoreDoing`'`._

## Narrative

**Business context:** 材料库存 → 材料库存查询 → 材料进销存报表 — current implementation of the material in-out-store (进销存) report. Per material/warehouse, shows opening balance, every in/out movement type aggregated, and closing balance over the user's date window. Replaces the earlier `SP_Inventory_InOutWareHouseAll` (now bound only to the "（旧）" legacy form) and the abandoned `Sp_Inventory_InOutStoreNew1` / `Sp_Inventory_InOutStoreNewTotal` forks.

**What it does:** Builds working set `p_TmpInOutStore` (and uniqueness helper `p_TmpInOutStore_uniq`) from `mitmaterialsstore`, `elematerialsstockmonth`, `eleproductstockmonth`, `elematerials`, joined to `siswarehouse`. Resolves form-config via `Sp_Sis_GetMertialsInventoryFormGuid`, supports per-material/style/warehouse/location filtering and dynamic `bFilter` predicates, and paginates via the standard report-tail pattern.

**Invocation:** Bound as the data source of form 材料进销存报表 (sId `192116810113315311950986680`) under 材料库存 → 材料库存查询 → 材料进销存报表 — loaded when the user opens the report; the form-binding dispatcher reads the proc name from `gdsconfigformmaster.sSqlStr`. No other DB or `xly-src` callers.
