# `Sp_SaleOrder_ProgressOfImplementation` (procedure)

> 订单(工单)执行情况


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 销售管理 → 订单(工单)执行情况 — full-lifecycle 订单全生命周期 progress tracker. COMMENT `'订单(工单)执行情况'`. For each 销售订单 line gives master/product fields, work-order qty/date/lag, 成品入库 qty/money/date, in-progress qty (`dProducting`), 送货 qty/money/date/未送 qty, 在途, 销售对账 (sSalesChecking) qty/money/未对账, 发票 qty/money/未发票, 回款 qty/money/已未回款, 结算方式 — i.e. one row collapses the full order→工单→入库→送货→对账→发票→回款 chain.

**What it does:** Builds the wide TEMP `p_TmpTb` (60+ columns with indexes on sSlaveId/sCustomerId/sProductId/tReportDate), populates the base row set from `Viw_SalSalesOrder` filtered to brand/sub. Applies `Fun_GetLookCustomer(sLoginId, sBrId, sSuId)` for row-level customer scoping. Multiple UPDATE … INNER JOIN passes layer in: work-order from `viw_mftworkorder`, 成品入库 / 在制 / 送货 / 销售对账 / 发票 / 回款 / 退货 from the matching `viw_*` views. Computes lag fields (`iFinishLag`, `iProductInLag`, `iLag`) and currency `dRoundingMoney`. Final dynamic SQL is fed to the standard paging helper for `bFilter`, `pageNum/pageSize`, `totalCount`, `countMapJson`, `sFilterOrderBy`, `sGroupby_*`.

**Invocation:** Bound as the data source of two 订单执行情况 forms via `gdsconfigformmaster.sSqlStr`:
- `19211681019715708434233300` — 销售订单执行情况
- `101251240115015897737820980` — 订单执行情况

Loaded when the user opens either report grid. xly-src ships the install + multiple upgrade scripts under `script/标版/30100101/`, `script/标版/upgrade/20220114-2862-…/`, `script/标版/upgrade/20220121-2839-…/`, `script/标版/optimize/`, and a customer-override under `script/客户/千彩/Sp_SaleOrder_ProgressOfImplementationNew.sql` — verify which build is deployed.
